8000 Merge pull request #1141 from lieryan/fix-move-refactoring · python-mode/python-mode@71a7f08 · GitHub
[go: up one dir, main page]

Skip to content

Commit 71a7f08

Browse files
authored
Merge pull request #1141 from lieryan/fix-move-refactoring
Fix Global and Module MoveRefactoring
2 parents 149ccf7 + b70ec57 commit 71a7f08

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

doc/pymode.txt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,14 +618,31 @@ code to call it instead.
618618
let g:pymode_rope_use_function_bind = '<C-c>ru'
619619
620620
621-
Move method/fields ~
621+
Move refactoring ~
622622
*pymode-rope-move*
623623

624+
Moving method/fields
625+
624626
It happens when you perform move refactoring on a method of a class. In this
625627
refactoring, a method of a class is moved to the class of one of its
626628
attributes. The old method will call the new method. If you want to change all
627629
of the occurrences of the old method to use the new method you can inline it
628630
afterwards.
631+
632+
Moving global variable/class/function into another module
633+
634+
It happens when you perform move refactoring on global variable/class/function.
635+
In this refactoring, the object being refactored will be moved to a destination
636+
module. All references to the object being moved will be updated to point to
637+
the new location.
638+
639+
Moving module variable/class/function into a package
640+
641+
It happens when you perform move refactoring on a name referencing a module.
642+
In this refactoring, the module being refactored will be moved to a destination
643+
package. All references to the object being moved will be updated to point to
644+
the new location.
645+
629646
>
630647
let g:pymode_rope_move_bind = '<C-c>rv'
631648

pymode/rope.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,15 @@ def get_refactor(ctx):
701701
offset = None
702702
return move.create_move(ctx.project, ctx.resource, offset)
703703

704+
@staticmethod
705+
def get_changes(refactor, input_str, in_hierarchy=False):
706+
with RopeContext() as ctx:
707+
if isinstance(refactor, (move.MoveGlobal, move.MoveModule)):
708+
dest = ctx.project.pycore.find_module(input_str)
709+
else:
710+
dest = input_str
711+
return super(MoveRefactoring, MoveRefactoring).get_changes(refactor, dest, in_hierarchy=in_hierarchy)
712+
704713

705714
class ChangeSignatureRefactoring(Refactoring):
706715

0 commit comments

Comments
 (0)
0