Add spaces around elvis operator

This commit is contained in:
Nikolay Krasko
2014-04-23 17:52:15 +04:00
parent 45013ce8af
commit d49d42a409
4 changed files with 29 additions and 3 deletions
@@ -55,6 +55,7 @@ fun createSpacingBuilder(settings: CodeStyleSettings): KotlinSpacingBuilder {
aroundInside(TokenSet.create(PLUS, MINUS), BINARY_EXPRESSION).spaceIf(jetCommonSettings.SPACE_AROUND_ADDITIVE_OPERATORS)
aroundInside(TokenSet.create(MUL, DIV, PERC), BINARY_EXPRESSION).spaceIf(jetCommonSettings.SPACE_AROUND_MULTIPLICATIVE_OPERATORS)
around(TokenSet.create(PLUSPLUS, MINUSMINUS, EXCLEXCL, MINUS, PLUS, EXCL)).spaceIf(jetCommonSettings.SPACE_AROUND_UNARY_OPERATOR)
around(ELVIS).spaces(1)
around(RANGE).spaceIf(jetSettings.SPACE_AROUND_RANGE)
afterInside(LPAR, VALUE_PARAMETER_LIST).spaces(0)
+11
View File
@@ -0,0 +1,11 @@
fun test(a: Int?) {
a ?: 42
a ?: 42
a ?:
42
a
?: 42
}
+11
View File
@@ -0,0 +1,11 @@
fun test(a: Int?) {
a?:42
a ?: 42
a ?:
42
a
?: 42
}
@@ -36,9 +36,7 @@ public class JetFormatterTestGenerated extends AbstractJetFormatterTest {
@InnerTestClasses({Formatter.ModifierList.class})
public static class Formatter extends AbstractJetFormatterTest {
public void testAllFilesPresentInFormatter() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage",
new File("idea/testData/formatter"), Pattern.compile("^([^\\.]+)\\.after\\.kt.*$"),
true);
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/formatter"), Pattern.compile("^([^\\.]+)\\.after\\.kt.*$"), true);
}
@TestMetadata("BinaryExpressions.after.kt")
@@ -106,6 +104,11 @@ public class JetFormatterTestGenerated extends AbstractJetFormatterTest {
doTest("idea/testData/formatter/ElseOnNewLine.after.kt");
}
@TestMetadata("Elvis.after.kt")
public void testElvis() throws Exception {
doTest("idea/testData/formatter/Elvis.after.kt");
}
@TestMetadata("EmptyLineAfterPackage.after.kt")
public void testEmptyLineAfterPackage() throws Exception {
doTest("idea/testData/formatter/EmptyLineAfterPackage.after.kt");