rope.refactor.introduce_parameter
Classes
Introduce parameter refactoring |
Module Contents
- class rope.refactor.introduce_parameter.IntroduceParameter(project, resource, offset)
Introduce parameter refactoring
This refactoring adds a new parameter to a function and replaces references to an expression in it with the new parameter.
The parameter finding part is different from finding similar pieces in extract refactorings. In this refactoring parameters are found based on the object they reference to. For instance in:
class A(object): var = None class B(object): a = A() b = B() a = b.a def f(a): x = b.a.var + a.var
using this refactoring on
a.varwithpas the new parameter name, will result in:def f(p=a.var): x = p + p
- project
- resource
- offset
- pymodule
- pyfunction
- get_changes(new_parameter)