RefactoringRope/RefactoringClient.py

branch
server_client_variant
changeset 185
3336637a673b
parent 184
4a806271f0b9
child 186
d547caa795d7
--- a/RefactoringRope/RefactoringClient.py	Sat Sep 23 16:52:29 2017 +0200
+++ b/RefactoringRope/RefactoringClient.py	Sat Sep 23 17:21:24 2017 +0200
@@ -78,6 +78,8 @@
             "CalculateRestructureChanges": self.__calculateRestructureChanges,
             "RequestSignature": self.__requestSignature,
             "CalculateSignatureChanges": self.__calculateSignatureChanges,
+            "CalculateInlineArgumentDefaultChanges":
+                self.__calculateInlineArgumentDefaultChanges,
         }
         
         from FileSystemCommands import RefactoringClientFileSystemCommands
@@ -1243,6 +1245,50 @@
         result.update(errorDict)
         
         self.sendJson("Changes", result)
+    
+    def __calculateInlineArgumentDefaultChanges(self, params):
+        """
+        Private method to calculate the 'Inline Argument Default' changes
+        based on the parameters sent by the server.
+        
+        @param params dictionary containing the method parameters sent by
+            the server
+        @type dict
+        """
+        changeGroup = params["ChangeGroup"]
+        title = params["Title"]
+        filename = params["FileName"]
+        offset = params["Offset"]
+        argumentIndex = params["Index"]
+        
+        errorDict = {}
+        result = {
+            "Subcommand": "Signature",
+            "ChangeGroup": changeGroup,
+            "Title": title,
+        }
+        
+        resource = rope.base.libutils.path_to_resource(
+            self.__project, filename)
+        self.__progressHandle = ProgressHandle(self, title, True)
+        try:
+            changer = rope.refactor.change_signature.ChangeSignature(
+                self.__project, resource, offset)
+            inliner = rope.refactor.change_signature.ArgumentDefaultInliner(
+                argumentIndex)
+            changes = changer.get_changes(
+                [inliner], task_handle=self.__progressHandle)
+        except Exception as err:
+            errorDict = self.__handleRopeError(err)
+        self.__progressHandle.reset()
+        self.__progressHandle = None
+        
+        self.__changes[changeGroup] = changes
+        
+        result["Subcommand"] = "ChangesCalculated"
+        result.update(errorDict)
+        
+        self.sendJson("Changes", result)
 
 
 if __name__ == '__main__':

eric ide

mercurial