30 """ |
30 """ |
31 Class implementing the code assist client interface to rope. |
31 Class implementing the code assist client interface to rope. |
32 """ |
32 """ |
33 PictureIDs = { |
33 PictureIDs = { |
34 "class": "?{0}".format(1), # Editor.ClassID |
34 "class": "?{0}".format(1), # Editor.ClassID |
|
35 "_class": "?{0}".format(2), # Editor.ClassProtectedID |
|
36 "__class": "?{0}".format(3), # Editor.ClassPrivateID |
35 "instance": "?{0}".format(1), # Editor.ClassID |
37 "instance": "?{0}".format(1), # Editor.ClassID |
|
38 "_instance": "?{0}".format(2), # Editor.ClassProtectedID |
|
39 "__instance": "?{0}".format(3), # Editor.ClassPrivateID |
36 "function": "?{0}".format(4), # Editor.MethodID |
40 "function": "?{0}".format(4), # Editor.MethodID |
|
41 "_function": "?{0}".format(5), # Editor.MethodProtectedID |
|
42 "__function": "?{0}".format(6), # Editor.MethodPrivateID |
37 "module": "?{0}".format(7), # Editor.AttributeID |
43 "module": "?{0}".format(7), # Editor.AttributeID |
|
44 "_module": "?{0}".format(8), # Editor.AttributeProtectedID |
|
45 "__module": "?{0}".format(9), # Editor.AttributePrivateID |
38 "None": "", |
46 "None": "", |
39 } |
47 } |
40 # The various ID values are a copy of the ones found in the Editor |
48 # The various ID values are a copy of the ones found in the Editor |
41 # class in order to make this module/script independent from an |
49 # class in order to make this module/script independent from an |
42 # installed eric |
50 # installed eric |
122 |
130 |
123 try: |
131 try: |
124 proposals = rope.contrib.codeassist.code_assist( |
132 proposals = rope.contrib.codeassist.code_assist( |
125 self.__project, source, offset, resource, maxfixes=maxfixes) |
133 self.__project, source, offset, resource, maxfixes=maxfixes) |
126 proposals = rope.contrib.codeassist.sorted_proposals(proposals) |
134 proposals = rope.contrib.codeassist.sorted_proposals(proposals) |
127 # TODO: extend this to include PictureIDs for protected and |
135 for proposal in proposals: |
128 # private stuff (i.e. names starting with _ or __) |
136 proposalType = proposal.type |
129 completions = [proposal.name + self.PictureIDs[proposal.type] |
137 if proposal.name.startswith("__"): |
130 for proposal in proposals] |
138 proposalType = "__" + proposalType |
|
139 elif proposal.name.startswith("_"): |
|
140 proposalType = "_" + proposalType |
|
141 completions.append( |
|
142 proposal.name + self.PictureIDs[proposalType]) |
131 except Exception as err: |
143 except Exception as err: |
132 errorDict = self.__handleRopeError(err) |
144 errorDict = self.__handleRopeError(err) |
133 |
145 |
134 result = { |
146 result = { |
135 "Completions": completions, |
147 "Completions": completions, |