RefactoringRope/CodeAssistClient.py

branch
server_client_variant
changeset 199
ae2ad82725b0
parent 198
898d8b4187de
child 200
1584892147ef
--- a/RefactoringRope/CodeAssistClient.py	Wed Sep 27 18:25:08 2017 +0200
+++ b/RefactoringRope/CodeAssistClient.py	Wed Sep 27 18:42:35 2017 +0200
@@ -59,6 +59,7 @@
         
         self.__methodMapping = {
             "getCompletions": self.__getCompletions,
+            "getCallTips": self.__getCallTips,
         }
         
         self.__projectpath = projectPath
@@ -135,6 +136,43 @@
         result.update(errorDict)
         
         self.sendJson("CompletionsResult", result)
+    
+    def __getCallTips(self, params):
+        """
+        Private method to calculate possible completions.
+        
+        @param params dictionary containing the method parameters
+        @type dict
+        """
+        filename = params["FileName"]
+        source = params["Source"]
+        offset = params["Offset"]
+        maxfixes = params["MaxFixes"]
+        
+        if filename:
+            resource = rope.base.libutils.path_to_resource(
+                self.__project, filename)
+        else:
+            resource = None
+        
+        errorDict = {}
+        calltips = []
+        
+        try:
+            cts = rope.contrib.codeassist.get_calltip(
+                self.__project, source, offset, resource, maxfixes=maxfixes,
+                remove_self=True)
+            if cts is not None:
+                calltips = [cts]
+        except Exception as err:
+            errorDict = self.__handleRopeError(err)
+        
+        result = {
+            "CallTips": calltips,
+        }
+        result.update(errorDict)
+        
+        self.sendJson("CallTipsResult", result)
 
 
 if __name__ == '__main__':

eric ide

mercurial