Refactoring for a project includes Find usages since in order to update all entities (occurrences, say, of a class, in files) of the project.
Operations of refactoring are Delete, Move, Rename.
For delete, if other entites use the entity to delete then a Refactoring UI would list those files in which the entity is used.
For Move and Rename, all references to the entity would be updated (fully qualified package name or if the filename changes then the constructor should be updated , in turn.
Use Cases
- Rename a bean class
- Move a bean class from one package to another
- Delete a bean class (may not be considered Spring)
- Find usages of a bean class (find all files and instances within the file where the bean class is used)
High-level design
A Base class of Refactoring operations uses a model to collect the files of a project to use a basis of what can be refactored.
Refactoring Factory
- implement RefactoringPluginFactory
- From the javadoc for RefactoringPluginFactory
/** Factory for a refactoring plugin (implementing {@link RefactoringPlugin} interface).
* Implementations of this factory can be registered to the lookup. The refactorings
* then get all the implementations of this interface from the lookup and call createInstance
* method passing "this" as a parameter.
*
*/
Refactoring Tree
- implement TreeElementFactoryImplementation
- From the javadoc of TreeElementFactoryImplementation :
/**
* Register your own TreeElementFactoryImplementation into META-INF/services
* if you want to build your own RefactoringPreview tree.
*
* For instance Java Refactoring understand Java - specific objects e.g.
* Projects, Groups, Methods etc.
*/
Refactoring operations base class
- implement RefactoringPlugin
- /** Interface implemented by refactoring plugins. Contains callback methods which a particular refactoring
* calls to check pre-conditions, validity of parameters and collect refactoring elements.
* It is expected that the refactoring that this plugin operates on is passed to the plugin
* in its constructor by a corresponding implementation of {@link RefactoringPluginFactory}.
*/
- implement XMLRefactoringPlugin
- Base class for all refactoring plugins that want to participate in the single global transaction
Refactoring operations (Delete, Move, Rename)
- extend a Plugin to implement each operation
- "Find" also extends Plugin to implement prepare(); other methods not used
Links/References