This plugin adds the final
modifier to each possible local parameter and variable when you save a Java class. Fields are left untouched.
Before:
class Foo {
int couldBeFinalField = 0;
void bar(int canBeFinalParameter) {
int canBeFinalVariable = 1;
}
}
After:
class Foo {
int couldBeFinalField = 0;
void bar(final int canBeFinalParameter) {
^^^^^
final int canBeFinalVariable = 1;
^^^^^
}
}
The plugin is meant to be used as quickly as possible. It has no configuration nor UI. It's a dynamic plugin, so you can install and uninstall it without restarting IntelliJ.
You can find this plugin in the marketplace.
Why not? Adding final
wherever possible is a convention in my team. The Save Actions Plugin is archived and didn't work correctly on newer versions of the IDE. IntelliJ's new "Actions on Save" tool requires too much configuration compared to the aforementioned plugin. I wanted something simple that just works. I also wanted to learn how to write a formatting plugin, so here we are.
- Save Actions Plugin for the inspiration.
- Flaticon.com for the plugin icon.
Plugin based on the IntelliJ Platform Plugin Template.