8000 add class hierarchy support to rename · dannon/python-mode@b2de6b0 · GitHub
[go: up one dir, main page]

Skip to content

Commit b2de6b0

Browse files
author
Dennis Brakhane
committed
add class hierarchy support to rename
When a method is renamed, the user can choose "perform in class hierarchy". This will rename methods of the same name in super- and subclasses. For example, in the following class A(object): def foo(self): pass class A2(A): def foo(self): pass class B(object): def foo(self): pass A normal rename in A2's foo will not rename A's foo and vice versa. With the "in class hierarchy" mode, both will be renamed. In both cases, class B will not be altered, as it isn't a super- or subclass. Fixes python-mode#456
1 parent 2d325c5 commit b2de6b0

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

pymode/rope.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -465,15 +465,19 @@ def run(self):
465465
if not input_str:
466466
return False
467467

468-
changes = self.get_changes(refactor, input_str)
469-
470468
action = env.user_input_choices(
471-
'Choose what to do:', 'perform', 'preview')
469+
'Choose what to do:', 'perform', 'preview',
470+
'perform in class hierarchy',
471+
'preview in class hierarchy')
472+
473+
in_hierarchy = action.endswith("in class hierarchy")
474+
475+
changes = self.get_changes(refactor, input_str, in_hierarchy)
472476

473477
if not action:
474478
return False
475479

476-
if action == 'preview':
480+
if action.startswith('preview'):
477481
print("\n ")
478482
print("-------------------------------")
479483
print("\n%s\n" % changes.get_description())
@@ -505,15 +509,15 @@ def get_input_str(refactor, ctx):
505509
return True
506510

507511
@staticmethod
508-
def get_changes(refactor, input_str):
512+
def get_changes(refactor, input_str, in_hierarchy=False):
509513
""" Get changes.
510514
511515
:return Changes:
512516
513517
"""
514518
progress = ProgressHandler('Calculate changes ...')
515519
return refactor.get_changes(
516-
input_str, task_handle=progress.handle)
520+
input_str, task_handle=progress.handle, in_hierarchy = in_hierarchy)
517521

518522

519523
class RenameRefactoring(Refactoring):

0 commit comments

Comments
 (0)
0