Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 28 additions & 40 deletions pymode/rope.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,14 +505,7 @@ def get_input_str(refactor, ctx):

@staticmethod
def get_changes(refactor, input_str, in_hierarchy=False):
""" Get changes.

:return Changes:

"""
progress = ProgressHandler('Calculate changes ...')
return refactor.get_changes(
input_str, task_handle=progress.handle, in_hierarchy = in_hierarchy)
raise NotImplementedError


class RenameRefactoring(Refactoring):
Expand Down Expand Up @@ -550,8 +543,26 @@ def get_input_str(self, refactor, ctx):

return newname

@staticmethod
def get_changes(refactor, input_str, in_hierarchy):
""" Get changes.

:return Changes:

"""
return refactor.get_changes(input_str, in_hierarchy=in_hierarchy)

class ExtractRefactoring(Refactoring):
@staticmethod
def get_changes(refactor, input_str, in_hierarchy):
""" Get changes.

:return Changes:

"""
return refactor.get_changes(input_str) #, global_=not in_hierarchy)

class ExtractMethodRefactoring(Refactoring):
class ExtractMethodRefactoring(ExtractRefactoring):

""" Extract method. """

Expand All @@ -574,18 +585,8 @@ def get_refactor(ctx):
return extract.ExtractMethod(
ctx.project, ctx.resource, offset1, offset2)

@staticmethod
def get_changes(refactor, input_str):
""" Get changes.

:return Changes:

"""

return refactor.get_changes(input_str)


class ExtractVariableRefactoring(Refactoring):
class ExtractVariableRefactoring(ExtractRefactoring):

""" Extract variable. """

Expand All @@ -608,16 +609,6 @@ def get_refactor(ctx):
return extract.ExtractVariable(
ctx.project, ctx.resource, offset1, offset2)

@staticmethod
def get_changes(refactor, input_str):
""" Get changes.

:return Changes:

"""

return refactor.get_changes(input_str)


class InlineRefactoring(Refactoring):

Expand All @@ -634,14 +625,13 @@ def get_refactor(ctx):
return inline.create_inline(ctx.project, ctx.resource, offset)

@staticmethod
def get_changes(refactor, input_str):
def get_changes(refactor, input_str, in_hierarchy):
""" Get changes.

:return Changes:

"""
progress = ProgressHandler('Calculate changes ...')
return refactor.get_changes(task_handle=progress.handle)
return refactor.get_changes()


class UseFunctionRefactoring(Refactoring):
Expand All @@ -659,15 +649,13 @@ def get_refactor(ctx):
return usefunction.UseFunction(ctx.project, ctx.resource, offset)

@staticmethod
def get_changes(refactor, input_str):
def get_changes(refactor, input_str, in_hierarchy):
""" Get changes.

:return Changes:

"""
progress = ProgressHandler('Calculate changes ...')
return refactor.get_changes(
resources=[refactor.resource], task_handle=progress.handle)
return refactor.get_changes()


class ModuleToPackageRefactoring(Refactoring):
Expand All @@ -684,7 +672,7 @@ def get_refactor(ctx):
return ModuleToPackage(ctx.project, ctx.resource)

@staticmethod
def get_changes(refactor, input_str):
def get_changes(refactor, input_str, in_hierarchy):
""" Get changes.

:return Changes:
Expand Down Expand Up @@ -746,7 +734,7 @@ def get_refactor(ctx):
return change_signature.ChangeSignature(
ctx.project, ctx.resource, offset)

def get_changes(self, refactor, input_string):
def get_changes(self, refactor, input_string, in_hierarchy):
""" Function description.

:return Rope.changes:
Expand All @@ -771,7 +759,7 @@ def get_changes(self, refactor, input_string):
changers.append(change_signature.ArgumentReorderer(
order, autodef='None'))

return refactor.get_changes(changers)
return refactor.get_changes(changers, in_hierarchy=in_hierarchy)


class GenerateElementRefactoring(Refactoring):
Expand Down