Formatting: omit blank lines between 'when' and left brace. Test is included.
This commit is contained in:
@@ -106,7 +106,10 @@ public class JetFormattingModelBuilder implements FormattingModelBuilder {
|
|||||||
.afterInside(COLON, TYPE_PARAMETER).spaceIf(jetSettings.SPACE_AFTER_EXTEND_COLON)
|
.afterInside(COLON, TYPE_PARAMETER).spaceIf(jetSettings.SPACE_AFTER_EXTEND_COLON)
|
||||||
|
|
||||||
.between(VALUE_ARGUMENT_LIST, FUNCTION_LITERAL_EXPRESSION).spaces(1)
|
.between(VALUE_ARGUMENT_LIST, FUNCTION_LITERAL_EXPRESSION).spaces(1)
|
||||||
|
|
||||||
|
//when
|
||||||
.aroundInside(ARROW, WHEN_ENTRY).spaceIf(jetSettings.SPACE_AROUND_WHEN_ARROW)
|
.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();
|
doTestWithInvert();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testWhenLinesBeforeLbrace() throws Exception {
|
||||||
|
doTest();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doTest() throws Exception {
|
public void doTest() throws Exception {
|
||||||
String originalFileText = AbstractJetFormatterTest.loadFile(getTestName(false) + ".kt");
|
String originalFileText = AbstractJetFormatterTest.loadFile(getTestName(false) + ".kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user