Is there an option to do the following in InteliJ IDEA automatically? Or some macro or something?
From:
a.equals(b)
To
b.equals(a)
There are times when there is a NPE in the first operand and so it breaks the flow. Like when comparing some string from an object to an enum value. Clean code says it should be like enum.equals(value)
and I want to do this at the press of keyboard shortcut.
CodePudding user response:
If you put your cursor anywhere within a.equals(b)
(even if it's after the closing parenthesis) and then press Alt-Enter, then you'll get a menu which includes "Flip '.equals'", which does exactly what you want.
An alternative way to get to that action is to press Ctrl-Shift-A to open the action search menu and enter any part of the name such as "flip".