Anonymous avatar Anonymous committed 6a748f8

Moved inline and module to package refactorings to ropemacs.refactor

Comments (0)

Files changed (2)

ropemacs/__init__.py

 
     @interactive
     def module_to_package(self):
-        self._check_project()
-        self._save_buffers(only_current=True)
-        packager = rope.refactor.ModuleToPackage(self.project,
-                                                 self._get_resource())
-        self._perform(packager.get_changes())
+        refactor.ModuleToPackage(self).show()
 
     def _do_extract(self, extractor, prompt):
         self._check_project()
 
     @interactive
     def inline(self):
-        self._check_project()
-        self._save_buffers()
-        resource, offset = self._get_location()
-        inliner = rope.refactor.inline.create_inline(
-            self.project, resource, offset)
-        self._perform(inliner.get_changes())
+        refactor.Inline(self).show()
 
     @interactive
     def restructure(self):
-        restruturing = refactor.Restructure(self)
-        return restruturing.show()
+        refactor.Restructure(self).show()
 
     @interactive
     def organize_imports(self):

ropemacs/refactor.py

+import rope.refactor.extract
+import rope.refactor.inline
+import rope.refactor.move
 import rope.refactor.move
 import rope.refactor.rename
 
     key = 'C-c r 1 v'
 
     offset = None
+
+
+class ModuleToPackage(Refactoring):
+
+    name = 'module_to_package'
+    key = 'C-c r 1 p'
+    saveall = False
+
+    def _create_refactoring(self):
+        self.packager = rope.refactor.ModuleToPackage(
+            self.project, self.resource)
+
+    def _calculate_changes(self, values):
+        return self.packager.get_changes()
+
+
+class Inline(Refactoring):
+
+    name = 'inline'
+    key = 'C-c r i'
+    saveall = False
+    optionals = {'remove': config.Data('Remove the definition: ',
+                                       values=['yes', 'no'])}
+
+    def _create_refactoring(self):
+        self.inliner = rope.refactor.inline.create_inline(
+            self.project, self.resource, self.offset)
+
+    def _calculate_changes(self, values):
+        remove = values.get('remove', 'yes') == 'yes'
+        return self.inliner.get_changes(remove=remove)
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.