How to setup IntelliJ IDEA 14 to add "final" keyword where possible?

Piotr Pradzynski picture Piotr Pradzynski · Apr 27, 2015 · Viewed 8.7k times · Source

I would like to setup my IntelliJ IDEA 14 for automatic final keyword adding in all possible places (parameters, fields, etc.) to the existing Java class. I found some solutions with macros and shortcuts but I would like setup IntelliJ to add the final keyword when it saves the file. Does anyone know a good solution for this? Maybe can you recommend some plugin or combination of plugins?

Answer

Steve Chaloner picture Steve Chaloner · Apr 27, 2015

Open the "Configure inspections" view (click on the person in the hat icon). Search on "final" and you'll find various options in the code style section that you can enable to enable highlighting of candidates for final. You can then use alt-return to apply the suggestion within a given file.

I wouldn't recommend you do it automatically on saving!