8000 Merge pull request #1143 from lieryan/lieryan-in-hierarchy · python-mode/python-mode@c86c4db · GitHub
[go: up one dir, main page]

Skip to content

Commit c86c4db

Browse files
authored
Merge pull request #1143 from lieryan/lieryan-in-hierarchy
Don't display in_hierarchy options that are not relevant to the current refactoring operation
2 parents 71a7f08 + 2b047c2 commit c86c4db

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

pymode/rope.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,10 +463,11 @@ def run(self):
463463
if not input_str:
464464
return False
465465

466+
code_actions = self.get_code_actions()
466467
action = env.user_input_choices(
467-
'Choose what to do:', 'perform', 'preview',
468-
'perform in class hierarchy',
469-
'preview in class hierarchy')
468+
'Choose what to do:',
469+
*code_actions,
470+
)
470471

471472
in_hierarchy = action.endswith("in class hierarchy")
472473

@@ -492,6 +493,12 @@ def run(self):
492493
except Exception as e: # noqa
493494
env.error('Unhandled exception in Pymode: %s' % e)
494495

496+
def get_code_actions(self):
497+
return [
498+
'perform',
499+
'preview',
500+
]
501+
495502
@staticmethod
496503
def get_refactor(ctx):
497504
""" Get refactor object. """
@@ -546,6 +553,14 @@ def get_input_str(self, refacto 10000 r, ctx):
546553

547554
return newname
548555

556+
def get_code_actions(self):
557+
return [
558+
'perform',
559+
'preview',
560+
'perform in class hierarchy',
561+
'preview in class hierarchy',
562+
]
563+
549564
@staticmethod
550565
def get_changes(refactor, input_str, in_hierarchy=False):
551566
""" Get changes.
@@ -708,7 +723,7 @@ def get_changes(refactor, input_str, in_hierarchy=False):
708723
dest = ctx.project.pycore.find_module(input_str)
709724
else:
710725
dest = input_str
711-
return super(MoveRefactoring, MoveRefactoring).get_changes(refactor, dest, in_hierarchy=in_hierarchy)
726+
return super(MoveRefactoring, MoveRefactoring).get_changes(refactor, dest)
712727

713728

714729
class ChangeSignatureRefactoring(Refactoring):
@@ -737,6 +752,14 @@ def get_refactor(ctx):
737752
return change_signature.ChangeSignature(
738753
ctx.project, ctx.resource, offset)
739754

755+
def get_code_actions(self):
756+
return [
757+
'perform',
758+
'preview',
759+
'perform in class hierarchy',
760+
'preview in class hierarchy',
761+
]
762+
740763
def get_changes(self, refactor, input_string, in_hierarchy=False):
741764
""" Function description.
742765

0 commit comments

Comments
 (0)
0