IDEA-57936 Not-compiling code after reformating in Java

Added special handling of situation when target region to surround by braces ends with single-line comment
This commit is contained in:
Denis Zhdanov
2010-08-27 10:50:37 +04:00
parent 5f4e236187
commit e5161c0e28
2 changed files with 36 additions and 3 deletions
@@ -73,4 +73,21 @@ public class JavaFormatterBracesTest extends AbstractJavaFormatterTest {
"if (x > y) { System.out.println(\"foo!\"); }"
);
}
public void testEnforcingBracesForExpressionEndingWithLineComment() throws Exception {
// Inspired by IDEA-57936
getSettings().IF_BRACE_FORCE = CodeStyleSettings.FORCE_BRACES_ALWAYS;
doMethodTest(
"if (true) i = 1; // Cool if\n" +
"else i = 2;",
"if (true) {\n" +
" i = 1; // Cool if\n" +
"}\n" +
"else {\n" +
" i = 2;\n" +
"}"
);
}
}