Commits

Anonymous committed 0e5a859

ropemacs: added rope-extract-method

Comments (0)

Files changed (1)

rope/contrib/ropemacs.py

         changes = renamer.get_changes(newname, docs=True)
         self._perform(changes)
 
-    @interactive('sNew Variable Name: ')
-    def extract_variable(self, newname):
+    def _do_extract(self, extractor, newname):
         self._check_project()
         lisp.save_buffer()
         resource = self._get_resource()
         start, end = self._get_region()
-        extractor = rope.refactor.extract.ExtractVariable(
-            self.project, resource, start, end)
+        extractor = extractor(self.project, resource, start, end)
         changes = extractor.get_changes(newname)
         self._perform(changes)
 
+    @interactive('sNew Variable Name: ')
+    def extract_variable(self, newname):
+        self._do_extract(rope.refactor.extract.ExtractVariable, newname)
+
+    @interactive('sNew Method Name: ')
+    def extract_method(self, newname):
+        self._do_extract(rope.refactor.extract.ExtractMethod, newname)
+
     def _perform(self, changes):
         self.project.do(changes)
         self._reload_buffers(changes.get_changed_resources())
 
 rename = interface.rename
 extract_variable = interface.extract_variable
+extract_method = interface.extract_method
 
 goto_definition = interface.goto_definition
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.