Anonymous avatar Anonymous committed 1bf437d

Added restructuring support

Comments (0)

Files changed (3)

 C-c r 1 v       rope-move-current-module
 C-c r 1 p       rope-module-to-package
 
-C-/             rope-code-assist
+M-/             rope-code-assist
 C-c g           rope-goto-definition
 C-c C-d         rope-show-doc
 C-c i o         rope-organize-imports
  Done
 ======
 
+- restructuring support : November 26, 2007
+- added ``rope-confirm-saving`` variable : November 26, 2007
+- only activating local keys in python mode : November 26, 2007
 - find file and advanced maching : November 25, 2007
 - generate python element; ``C-c n [vfcmp]`` : November 23, 2007
 - rope find file; ``C-c p f`` : November 23, 2007
 - code-assist; ``M-/`` : November 23, 2007
 
-> Public Release 0.6.2 : September 9, 2007
+> Public Release 0.1 : September 9, 2007
 
 - moving elements, methods and modules : October 30, 2007
 - undoing refactorings : October 29, 2007

ropemacs/__init__.py

 import rope.refactor.inline
 import rope.refactor.move
 import rope.refactor.rename
+import rope.refactor.restructure
 from Pymacs import lisp
 from rope.base import project, libutils
 from rope.contrib import codeassist, generate
             ('C-c r m', lisp.rope_extract_method),
             ('C-c r i', lisp.rope_inline),
             ('C-c r v', lisp.rope_move),
+            ('C-c r x', lisp.rope_restructure),
             ('C-c r 1 r', lisp.rope_rename_current_module),
             ('C-c r 1 v', lisp.rope_move_current_module),
             ('C-c r 1 p', lisp.rope_module_to_package),
         self._perform(inliner.get_changes())
 
     @interactive
+    def restructure(self):
+        self._check_project()
+        pattern = _ask("Restructuring pattern: ")
+        goal = _ask("Restructuring goal: ")
+        restructuring = rope.refactor.restructure.Restructure(self.project,
+                                                              pattern, goal)
+        raw_checks = _ask("Restructuring checks: ")
+        check_dict = {}
+        for raw_check in raw_checks.split('\n'):
+            if raw_check:
+                key, value = raw_check.split('==')
+                check_dict[key.strip()] = value.strip()
+        checks = restructuring.make_checks(check_dict)
+        imports = [line.strip() for line in _ask("Imports: ").split('\n')]
+        changes = restructuring.get_changes(checks=checks, imports=imports)
+        self._perform(changes)
+
+    @interactive
     def organize_imports(self):
         self._check_project()
         self._save_buffers(only_current=True)
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.