refactor
refactor copied to clipboard
Don't re-create rules on each refactoring iteration
I am missing global state per file. For example: Renaming a method
- update import
- rename usages
I have a Rule derived class that finds the correct Import and returns a ReplacementAction. I would need to store an alias into some file global context and match all the ast.Call to create ReplacementAction.
Now any data stored inside Rule or context provider is recreated after every ReplacementAction ...
Basically: rules = self._initialize_rules(tree, source, file)
should be run outside and before _run ... there is probably no need to recreate rules after each change?