New setting and test: space before lambda arrow

#KT-3932 fixed
This commit is contained in:
sayon
2013-08-27 16:22:20 +04:00
parent 523a5bf6a9
commit a0500f56d2
7 changed files with 20 additions and 0 deletions
@@ -37,6 +37,7 @@ public class JetCodeStyleSettings extends CustomCodeStyleSettings {
public boolean SPACE_AROUND_FUNCTION_TYPE_ARROW = true;
public boolean SPACE_AROUND_WHEN_ARROW = true;
public boolean SPACE_BEFORE_LAMBDA_ARROW = true;
public static JetCodeStyleSettings getInstance(Project project) {
return CodeStyleSettingsManager.getSettings(project).getCustomSettings(JetCodeStyleSettings.class);
@@ -106,6 +106,7 @@ public class JetFormattingModelBuilder implements FormattingModelBuilder {
.afterInside(COLON, TYPE_PARAMETER).spaceIf(jetSettings.SPACE_AFTER_EXTEND_COLON)
.between(VALUE_ARGUMENT_LIST, FUNCTION_LITERAL_EXPRESSION).spaces(1)
.beforeInside(ARROW, FUNCTION_LITERAL).spaceIf(jetSettings.SPACE_BEFORE_LAMBDA_ARROW)
//when
.aroundInside(ARROW, WHEN_ENTRY).spaceIf(jetSettings.SPACE_AROUND_WHEN_ARROW)
@@ -130,6 +130,11 @@ public class JetLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSetti
consumer.showCustomOption(JetCodeStyleSettings.class, "SPACE_AROUND_WHEN_ARROW",
"Surround arrow in \"when\" clause with spaces",
CodeStyleSettingsCustomizable.SPACES_OTHER);
consumer.showCustomOption(JetCodeStyleSettings.class, "SPACE_BEFORE_LAMBDA_ARROW",
"Before lambda arrow",
CodeStyleSettingsCustomizable.SPACES_OTHER);
break;
case WRAPPING_AND_BRACES_SETTINGS:
consumer.showStandardOptions(
+3
View File
@@ -0,0 +1,3 @@
val f: (Int, Int, Int) -> Int = { x, y, z -> x + y + z }
// SET_FALSE: SPACE_BEFORE_LAMBDA_ARROW
@@ -0,0 +1,3 @@
val f: (Int, Int, Int) -> Int = { x, y, z-> x + y + z }
// SET_FALSE: SPACE_BEFORE_LAMBDA_ARROW
@@ -0,0 +1,3 @@
val f: (Int, Int, Int) -> Int = { x, y, z -> x + y + z }
// SET_FALSE: SPACE_BEFORE_LAMBDA_ARROW
@@ -143,6 +143,10 @@ public class JetFormatterTest extends AbstractJetFormatterTest {
doTestWithInvert();
}
public void testLambdaArrow() throws Exception {
doTestWithInvert();
}
@Override
public void doTest() throws Exception {
String originalFileText = AbstractJetFormatterTest.loadFile(getTestName(false) + ".kt");