package org.intellij;
/**
* User: Alex
*/
public class TestWrapBraces
{
publicboolean foo(int i) {
if (i > 0)
returntrue;
elsereturnfalse;
}
}
If I have "Control flow statement without braces" inspection turned on, I will see warnings
on the if and else blocks:
'if' without braces
'elsel without braces
I can use ALT+ENTER on both if and else to add braces or I can hit ALT+ENTER once on
one of them and then RIGHT_ARROW and ENTER on 'Fix all 'Control flow statement without braces' problems.
Either way I end up with:
TestWrapBraces.java - After Fix
package org.intellij;
/**
* User: Alex
*/
public class TestWrapBraces
{
publicboolean foo(int i) {
if (i > 0) {
returntrue;
}
else {
returnfalse;
}
}
}
The problem is that IDEA is not using the settings for 'Place on New Line'. (See screenshot).
I have "else" on new line disabled, so I would expected the Quickfix to put the else after the closing
brace.
Here is what I get if I reformat the code either before or after I made the quickfixes. (Reformat also
inserts braces automatically.)
TestWrapBraces.java – After Reformat
package org.intellij;
/**
* User: Alex
*/
public class TestWrapBraces
{
publicboolean foo(int i) {
if (i > 0) {
returntrue;
} else {
returnfalse;
}
}
}
The reason it is important to fix this QuickFix is that in a team environment, we try not to Reformat the entire file. So, that
isn't a good workaround. It would be much better if the quickfix could produce could which matches what the reformat
would have done.
Description
Given the following code:
TestWrapBraces.java
package org.intellij;
/**
* User: Alex
*/
public class TestWrapBraces
{
publicboolean foo(int i) {
if (i > 0)
returntrue;
elsereturnfalse;
}
}
If I have "Control flow statement without braces" inspection turned on, I will see warnings
on the if and else blocks:
'if' without braces
'elsel without braces
I can use ALT+ENTER on both if and else to add braces or I can hit ALT+ENTER once on
one of them and then RIGHT_ARROW and ENTER on 'Fix all 'Control flow statement without braces' problems.
Either way I end up with:
TestWrapBraces.java - After Fix
package org.intellij;
/**
* User: Alex
*/
public class TestWrapBraces
{
publicboolean foo(int i) {
if (i > 0) {
returntrue;
}
else {
returnfalse;
}
}
}
The problem is that IDEA is not using the settings for 'Place on New Line'. (See screenshot).
I have "else" on new line disabled, so I would expected the Quickfix to put the else after the closing
brace.
Here is what I get if I reformat the code either before or after I made the quickfixes. (Reformat also
inserts braces automatically.)
TestWrapBraces.java – After Reformat
package org.intellij;
/**
* User: Alex
*/
public class TestWrapBraces
{
publicboolean foo(int i) {
if (i > 0) {
returntrue;
} else {
returnfalse;
}
}
}
The reason it is important to fix this QuickFix is that in a team environment, we try not to Reformat the entire file. So, that
isn't a good workaround. It would be much better if the quickfix could produce could which matches what the reformat
would have done.