57 """ |
57 """ |
58 super(CodeAssistClient, self).__init__(host, port, idString) |
58 super(CodeAssistClient, self).__init__(host, port, idString) |
59 |
59 |
60 self.__methodMapping = { |
60 self.__methodMapping = { |
61 "getCompletions": self.__getCompletions, |
61 "getCompletions": self.__getCompletions, |
|
62 "getCallTips": self.__getCallTips, |
62 } |
63 } |
63 |
64 |
64 self.__projectpath = projectPath |
65 self.__projectpath = projectPath |
65 self.__project = rope.base.project.Project(self.__projectpath) |
66 self.__project = rope.base.project.Project(self.__projectpath) |
66 self.__project.validate(self.__project.root) |
67 self.__project.validate(self.__project.root) |
133 "Completions": completions, |
134 "Completions": completions, |
134 } |
135 } |
135 result.update(errorDict) |
136 result.update(errorDict) |
136 |
137 |
137 self.sendJson("CompletionsResult", result) |
138 self.sendJson("CompletionsResult", result) |
|
139 |
|
140 def __getCallTips(self, params): |
|
141 """ |
|
142 Private method to calculate possible completions. |
|
143 |
|
144 @param params dictionary containing the method parameters |
|
145 @type dict |
|
146 """ |
|
147 filename = params["FileName"] |
|
148 source = params["Source"] |
|
149 offset = params["Offset"] |
|
150 maxfixes = params["MaxFixes"] |
|
151 |
|
152 if filename: |
|
153 resource = rope.base.libutils.path_to_resource( |
|
154 self.__project, filename) |
|
155 else: |
|
156 resource = None |
|
157 |
|
158 errorDict = {} |
|
159 calltips = [] |
|
160 |
|
161 try: |
|
162 cts = rope.contrib.codeassist.get_calltip( |
|
163 self.__project, source, offset, resource, maxfixes=maxfixes, |
|
164 remove_self=True) |
|
165 if cts is not None: |
|
166 calltips = [cts] |
|
167 except Exception as err: |
|
168 errorDict = self.__handleRopeError(err) |
|
169 |
|
170 result = { |
|
171 "CallTips": calltips, |
|
172 } |
|
173 result.update(errorDict) |
|
174 |
|
175 self.sendJson("CallTipsResult", result) |
138 |
176 |
139 |
177 |
140 if __name__ == '__main__': |
178 if __name__ == '__main__': |
141 if len(sys.argv) != 5: |
179 if len(sys.argv) != 5: |
142 print('Host, port, id and project path parameters are missing. Abort.') |
180 print('Host, port, id and project path parameters are missing. Abort.') |