dubreuia / intellij-plugin-save-actions

Supports configurable, Eclipse like, save actions, including "organize imports", "reformat code" and "rearrange code".
MIT License
531 stars 101 forks source link

Flip operands of equals method #354

Closed rw00 closed 3 years ago

rw00 commented 3 years ago

Given code similar to the following:/0

public static final String CONST = "...";
...
String k = ...;
if (k.equals(CONST)) {
 ...
}

Then there should be an option to automatically flip the operands of the equals method. After save, the code should look like:

if (CONST.equals(k)) {

}

The downside of this is that it might hide NPEs.

This should be doable in IntelliJ because there's already a runnable action for it.

dubreuia commented 3 years ago

Hello @rw00 :wave:, thank you for opening this. This is a great idea, but I won't have time to implement this. But I'm accepting PRs, a adding an (existing) quick fix is really easy, if you want to look at it.

dubreuia commented 3 years ago

Move to https://github.com/dubreuia/intellij-plugin-save-actions/projects/2 (ideas)