Reputation: 340118
Some people like to omit the this.
prefix to calls, such as:
addColor( Color.PURPLE ) ;
… while other folks prefer to include explicitly the this.
prefix, such as:
this.addColor( Color.PURPLE ) ;
Does IntelliJ offer any feature for automatically adding and/or removing the this.
prefix within the code shown in the editor?
Upvotes: 2
Views: 734
Reputation: 5261
The plugin, Save Actions, offers this functionality.
When installed (and activated) you can find these options under Other Settings -> Save Actions:
The plugin can be configured to execute these actions on save / idling / window deactivation.
InteliJ IDEA itself offers these checkstyle functionalities:
Ctrl + Alt + S -> Editor -> Inspections -> Code style issues:
To inspect the code and apply the fix: Code -> Inspect
To auto apply fixes: Code -> Cleanup
Upvotes: 2
Reputation: 26577
IntelliJ has the following inspections to add a this
qualifier to method calls and field references:
Java | Code style issues | Instance field access not qualified with 'this'
Java | Code style issues | Instance method call not qualified with 'this'
And the following inspection to remove unnecessary this
qualifiers:
Java | Code style issues | Unnecessary 'this' qualifier
All three inspections have a quick fix, and code can be fixed in batch using Code | Inspect Code
and applying the fix on the result or Code | Cleanup
to immediately clean up the code.
The Save Actions plugin just calls these built-in inspections.
Upvotes: 2