23 import rope.base.libutils |
23 import rope.base.libutils |
24 import rope.contrib.codeassist |
24 import rope.contrib.codeassist |
25 |
25 |
26 from PyQt5.QtCore import QObject |
26 from PyQt5.QtCore import QObject |
27 |
27 |
|
28 from QScintilla.Editor import Editor |
|
29 |
28 import Globals |
30 import Globals |
29 |
31 |
30 |
32 |
31 class CodeAssist(QObject): |
33 class CodeAssist(QObject): |
32 """ |
34 """ |
33 Class implementing the autocompletion interface to rope. |
35 Class implementing the autocompletion interface to rope. |
34 """ |
36 """ |
|
37 PictureIDs = { |
|
38 "class": "?{0}".format(Editor.ClassID), |
|
39 "instance": "?{0}".format(Editor.ClassID), |
|
40 "function": "?{0}".format(Editor.MethodID), |
|
41 "module": "?{0}".format(Editor.AttributeID), |
|
42 "None": "", |
|
43 } |
|
44 |
35 def __init__(self, plugin, parent=None): |
45 def __init__(self, plugin, parent=None): |
36 """ |
46 """ |
37 Constructor |
47 Constructor |
38 |
48 |
39 @param plugin reference to the plugin object |
49 @param plugin reference to the plugin object |
66 maxfixes = self.__plugin.getPreferences("MaxFixes") |
76 maxfixes = self.__plugin.getPreferences("MaxFixes") |
67 try: |
77 try: |
68 proposals = rope.contrib.codeassist.code_assist( |
78 proposals = rope.contrib.codeassist.code_assist( |
69 self.__project, source, offset, resource, maxfixes=maxfixes) |
79 self.__project, source, offset, resource, maxfixes=maxfixes) |
70 proposals = rope.contrib.codeassist.sorted_proposals(proposals) |
80 proposals = rope.contrib.codeassist.sorted_proposals(proposals) |
71 names = [proposal.name for proposal in proposals] |
81 names = [proposal.name + self.PictureIDs[proposal.type] |
|
82 for proposal in proposals] |
72 return names |
83 return names |
73 except Exception: |
84 except Exception: |
74 return [] |
85 return [] |
75 |
86 |
76 def getCallTips(self, pos, editor): |
87 def getCallTips(self, pos, editor): |