Last week I wanted to rename a larger amount of Java types so that they are consistent with a new naming scheme. This does not seem to be easily possible in IntelliJ, so I wrote a small plugin that imports a CSV file with the ‘refactoring instructions’ and runs them in bulk. It also allows to define type-specific refactoring options, such as telling IntelliJ to also replace occurrences of the type name in other text files.
The developers at JetBrains really put some effort into supporting plugin developers. There are many helpful context-specific messages,
e.g. to inform you about APIs that are soon to be deprecated, or what exactly you forgot to put into your plugin.xml
.
The latter even comes with a custom auto-complete for module dependencies.
There were a few minor roadblocks1, but nothing serious. This is the power of dogfooding, I guess.
This was a weekend project, so while I’m happy with the refactoring result itself, there are many rough edges (and I’m pretty sure there are better ways to use the IntelliJ API). Nevertheless, it may be a useful blueprint for implementing similar utilities that help with larger ‘one-off’ refactorings.
For example, the predefined gradle setup requires more than the default RAM on my machine, so a custom setting in the gradle.properties
file was required to initially configure the project. ↩