やりたいこと
- Javaのコードを書くときに、immutableにしたい変数には、finalを付けておきたい
- ただ毎回finalを書くのは大変なので、ファイル保存時に自動的にfinalを付けるようにしたい
環境
- IntelliJ IDEA 2020.2.2
- Mac OS Catalina 10.15.7
やり方
Save Actions プラグインを利用するので、「IntelliJ IDEA」 -> 「Preferences」 -> 「Plugins」 を押下して、Save Actionsをインストール
「IntelliJ IDEA」 -> 「Preferences」 -> 「Other Settings」 -> 「Save Actions」を押下して、
以下の項目にチェックを入れ、「Apply」, 「OK」を押下
- Activate save actions on save (...)
- Add final modifier to field
- Add final modifier to local variable or parameter
- (もしくは Add final modifier to local variable or parameter except if it is implicit)