Formatting: omit blank lines between 'when' and left brace. Test is included.

This commit is contained in:
sayon
2013-08-28 15:15:16 +04:00
parent f8b280ba57
commit 965265b8b8
4 changed files with 31 additions and 0 deletions
@@ -106,7 +106,10 @@ public class JetFormattingModelBuilder implements FormattingModelBuilder {
.afterInside(COLON, TYPE_PARAMETER).spaceIf(jetSettings.SPACE_AFTER_EXTEND_COLON)
.between(VALUE_ARGUMENT_LIST, FUNCTION_LITERAL_EXPRESSION).spaces(1)
//when
.aroundInside(ARROW, WHEN_ENTRY).spaceIf(jetSettings.SPACE_AROUND_WHEN_ARROW)
.beforeInside(LBRACE, WHEN).spacing(1, 1, 0, true, 0) //omit blank lines before '{' in 'when' statement
;
}
@@ -0,0 +1,17 @@
fun f(x: Any): Int {
return when (x)
{
is Int->1
else->0
}
}
@@ -0,0 +1,7 @@
fun f(x: Any): Int {
return when (x)
{
is Int -> 1
else -> 0
}
}
@@ -135,6 +135,10 @@ public class JetFormatterTest extends AbstractJetFormatterTest {
doTestWithInvert();
}
public void testWhenLinesBeforeLbrace() throws Exception {
doTest();
}
@Override
public void doTest() throws Exception {
String originalFileText = AbstractJetFormatterTest.loadFile(getTestName(false) + ".kt");