New setting and test: space before lambda arrow
#KT-3932 fixed
This commit is contained in:
@@ -37,6 +37,7 @@ public class JetCodeStyleSettings extends CustomCodeStyleSettings {
|
|||||||
public boolean SPACE_AROUND_FUNCTION_TYPE_ARROW = true;
|
public boolean SPACE_AROUND_FUNCTION_TYPE_ARROW = true;
|
||||||
|
|
||||||
public boolean SPACE_AROUND_WHEN_ARROW = true;
|
public boolean SPACE_AROUND_WHEN_ARROW = true;
|
||||||
|
public boolean SPACE_BEFORE_LAMBDA_ARROW = true;
|
||||||
|
|
||||||
public static JetCodeStyleSettings getInstance(Project project) {
|
public static JetCodeStyleSettings getInstance(Project project) {
|
||||||
return CodeStyleSettingsManager.getSettings(project).getCustomSettings(JetCodeStyleSettings.class);
|
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)
|
.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)
|
||||||
|
.beforeInside(ARROW, FUNCTION_LITERAL).spaceIf(jetSettings.SPACE_BEFORE_LAMBDA_ARROW)
|
||||||
|
|
||||||
//when
|
//when
|
||||||
.aroundInside(ARROW, WHEN_ENTRY).spaceIf(jetSettings.SPACE_AROUND_WHEN_ARROW)
|
.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",
|
consumer.showCustomOption(JetCodeStyleSettings.class, "SPACE_AROUND_WHEN_ARROW",
|
||||||
"Surround arrow in \"when\" clause with spaces",
|
"Surround arrow in \"when\" clause with spaces",
|
||||||
CodeStyleSettingsCustomizable.SPACES_OTHER);
|
CodeStyleSettingsCustomizable.SPACES_OTHER);
|
||||||
|
|
||||||
|
consumer.showCustomOption(JetCodeStyleSettings.class, "SPACE_BEFORE_LAMBDA_ARROW",
|
||||||
|
"Before lambda arrow",
|
||||||
|
CodeStyleSettingsCustomizable.SPACES_OTHER);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case WRAPPING_AND_BRACES_SETTINGS:
|
case WRAPPING_AND_BRACES_SETTINGS:
|
||||||
consumer.showStandardOptions(
|
consumer.showStandardOptions(
|
||||||
|
|||||||
@@ -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();
|
doTestWithInvert();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testLambdaArrow() throws Exception {
|
||||||
|
doTestWithInvert();
|
||||||
|
}
|
||||||
|
|
||||||
@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