Commits

Ali Gholami Rudi  committed 2b81624

refactor: added usefunction refactoring

  • Participants
  • Parent commits 59438bd

Comments (0)

Files changed (3)

File docs/done.txt

 ===========
 
 
+- Added usefunction refactoring : January 29, 2008
+
+
 > Public Release 1.5 : January 17, 2008
 
 

File ropeide/dot_ropeide.py

     core.rebind_action('move', 'M-V')
     core.rebind_action('extract_method', 'M-M')
     core.rebind_action('inline', 'M-I')
+    core.rebind_action('usefunction', None)
     core.rebind_action('extract_local_variable', 'M-L')
     core.rebind_action('rename_in_file', None)
     core.rebind_action('change_signature', 'M-C')

File ropeide/refactor.py

 def inline(context):
     InlineDialog(context).show()
 
+class UseFunctionDialog(RefactoringDialog):
+
+    def __init__(self, context):
+        self.user = rope.refactor.usefunction.UseFunction(
+            context.project, context.resource, context.offset)
+        super(UseFunctionDialog, self).__init__(
+            context, 'Using Function <%s>' %
+            self.user.get_function_name())
+
+    def _calculate_changes(self, handle):
+        return self.user.get_changes(task_handle=handle)
+
+    def _get_dialog_frame(self):
+        frame = Tkinter.Frame(self.toplevel)
+        label = Tkinter.Label(frame, text='Using Function <%s>' %
+                              self.user.get_function_name(), width=50)
+        label.grid(row=1)
+        frame.grid()
+        return frame
+
+
+def usefunction(context):
+    UseFunctionDialog(context).show()
+
 
 def encapsulate_field(context):
     if context.get_active_editor():
                             MenuAddress(['Refactor', 'Move'], 'v'), ['python']))
 actions.append(SimpleAction('inline', ConfirmEditorsAreSaved(inline), 'C-c r i',
                             MenuAddress(['Refactor', 'Inline'], 'i'), ['python']))
+actions.append(SimpleAction(
+               'usefunction', ConfirmEditorsAreSaved(usefunction), 'C-c r u',
+               MenuAddress(['Refactor', 'UseFunction'], 'u'), ['python']))
 actions.append(SimpleAction('extract_local_variable',
                             ConfirmEditorsAreSaved(extract_variable, all=False), 'C-c r l',
                             MenuAddress(['Refactor', 'Extract Local Variable'], 'l'), ['python']))