Reputation: 20163
How can IntelliJ's structural replace feature be used to find all if statements having exactly one line (that's executed when the condition is met)
if (isNice)
doSomething();
and surround them with curly braces?
if (isNice) {
doSomething();
}
Surprisingly, this
if ($expression$)
$expression2$;
is finding if blocks with or without curlys...although I'm not sure this is on the right path to begin with...
Upvotes: 4
Views: 780
Reputation: 26462
What you want is currently not possible with Structural Search and Replace. There is however a different way to achieve the desired result: the Control flow statement without braces inspection. It has a quick fix to add braces.
Upvotes: 4