RefactoringRope/Refactoring.py

branch
server_client_variant
changeset 175
72a1d9030d67
parent 174
04583cac110f
child 176
117d86025a5c
diff -r 04583cac110f -r 72a1d9030d67 RefactoringRope/Refactoring.py
--- a/RefactoringRope/Refactoring.py	Tue Sep 19 19:40:18 2017 +0200
+++ b/RefactoringRope/Refactoring.py	Wed Sep 20 19:49:26 2017 +0200
@@ -1005,16 +1005,17 @@
         """
         self.__doExtract(self.tr("Extract Local Variable"), "variable")
     
-    # TODO: continue from here
     def __doExtract(self, title, kind):
         """
         Private method to perform the extract refactoring.
         
-        @param title title of the refactoring (string)
-        @param kind kind of extraction to be done (string,
-            "method" or "variable")
-        @exception Exception raised to indicate a wrong extraction method
+        @param title title of the refactoring
+        @type str
+        @param kind kind of extraction to be done
+        @type str ("method" or "variable")
         """
+        assert kind in ["variable", "method"]
+        
         aw = e5App().getObject("ViewManager").activeWindow()
         
         if aw is None:
@@ -1036,30 +1037,20 @@
         startOffset = self.__getOffset(aw, startline, startcolumn)
         endOffset = self.__getOffset(aw, endline, endcolumn)
         
-        import rope.refactor.extract
-        resource = rope.base.libutils.path_to_resource(
-            self.__project, filename)
-        try:
-            if kind == "variable":
-                extractor = rope.refactor.extract.ExtractVariable(
-                    self.__project, resource, startOffset, endOffset)
-            elif kind == "method":
-                extractor = rope.refactor.extract.ExtractMethod(
-                    self.__project, resource, startOffset, endOffset)
-            else:
-                raise Exception("Invalid extraction kind <{0}>.".format(kind))
-        except Exception as err:
-            self.handleRopeError(err, title)
-            return
-        
         from ExtractDialog import ExtractDialog
-        self.dlg = ExtractDialog(self, title, extractor, parent=self.__ui)
-        self.dlg.show()
+        dlg = ExtractDialog(self, title, filename, startOffset, endOffset,
+                            kind, parent=self.__ui)
+        changeGroup = dlg.getChangeGroupName()
+        self.__refactoringDialogs[changeGroup] = dlg
+        dlg.finished.connect(
+            lambda: self.__refactoringDialogClosed(changeGroup))
+        dlg.show()
     
     #####################################################
     ## Inline refactorings
     #####################################################
     
+    # TODO: continue from here
     def __inline(self):
         """
         Private slot to handle the Inline Local Variable action.

eric ide

mercurial