JavaFormatter: space before "{" processing corrected (fixes IDEA-127110). Now four cases are checked, depending on braces placement option:

- when place brace on the end of line is on
- when option place brace next line if wrapped is on
- when place brace on next line is on and keep simple blocks/methods/classes option is on
- when place brace on next line is on
This commit is contained in:
Yaroslav Lepenkin
2014-08-13 12:40:24 +04:00
parent 788de8b17e
commit add049df39
2 changed files with 195 additions and 117 deletions
@@ -242,4 +242,51 @@ public class JavaFormatterBracesTest extends AbstractJavaFormatterTest {
doMethodTest(singleLine, multiLine);
doMethodTest(multiLine, multiLine);
}
public void testMethodBraceOnNextLineIfWrapped() {
getSettings().METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED;
getSettings().METHOD_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
getSettings().RIGHT_MARGIN = 50;
doClassTest(
"public static void main(int state, int column, int width, int rate) {\n" +
"}\n",
"public static void main(int state, int column,\n" +
" int width, int rate)\n" +
"{\n" +
"}\n"
);
}
public void testIDEA127110() {
getSettings().KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED;
doMethodTest(
"if ( 1 > 2) {\n" +
"\n" +
"} else {\n" +
"\n" +
"}\n" +
"\n" +
"try {\n" +
"\n" +
"} catch ( Exception e) {\n" +
"\n" +
"} finally {\n" +
"\n" +
"}",
"if (1 > 2) {\n" +
"\n" +
"} else {\n" +
"\n" +
"}\n" +
"\n" +
"try {\n" +
"\n" +
"} catch (Exception e) {\n" +
"\n" +
"} finally {\n" +
"\n" +
"}"
);
}
}