New setting and test: space around arrow in function types
This commit is contained in:
@@ -34,6 +34,8 @@ public class JetCodeStyleSettings extends CustomCodeStyleSettings {
|
|||||||
public boolean INSERT_WHITESPACES_IN_SIMPLE_ONE_LINE_METHOD = true;
|
public boolean INSERT_WHITESPACES_IN_SIMPLE_ONE_LINE_METHOD = true;
|
||||||
public boolean ALIGN_IN_COLUMNS_CASE_BRANCH = false;
|
public boolean ALIGN_IN_COLUMNS_CASE_BRANCH = false;
|
||||||
|
|
||||||
|
public boolean SPACE_AROUND_FUNCTION_TYPE_ARROW = true;
|
||||||
|
|
||||||
public boolean SPACE_AROUND_WHEN_ARROW = true;
|
public boolean SPACE_AROUND_WHEN_ARROW = true;
|
||||||
|
|
||||||
public static JetCodeStyleSettings getInstance(Project project) {
|
public static JetCodeStyleSettings getInstance(Project project) {
|
||||||
|
|||||||
@@ -110,6 +110,8 @@ public class JetFormattingModelBuilder implements FormattingModelBuilder {
|
|||||||
//when
|
//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
|
.beforeInside(LBRACE, WHEN).spacing(1, 1, 0, true, 0) //omit blank lines before '{' in 'when' statement
|
||||||
|
|
||||||
|
.aroundInside(ARROW, FUNCTION_TYPE).spaceIf(jetSettings.SPACE_AROUND_FUNCTION_TYPE_ARROW)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -123,6 +123,10 @@ public class JetLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSetti
|
|||||||
"Insert whitespaces in simple one line methods",
|
"Insert whitespaces in simple one line methods",
|
||||||
CodeStyleSettingsCustomizable.SPACES_OTHER);
|
CodeStyleSettingsCustomizable.SPACES_OTHER);
|
||||||
|
|
||||||
|
consumer.showCustomOption(JetCodeStyleSettings.class, "SPACE_AROUND_FUNCTION_TYPE_ARROW",
|
||||||
|
"Surround arrow in function types with spaces",
|
||||||
|
CodeStyleSettingsCustomizable.SPACES_OTHER);
|
||||||
|
|
||||||
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);
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
fun test(some: ((Int)->Int) ->Int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// SET_TRUE: SPACE_AROUND_FUNCTION_TYPE_ARROW
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
fun test(some: ((Int) -> Int) -> Int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// SET_TRUE: SPACE_AROUND_FUNCTION_TYPE_ARROW
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
fun test(some: ((Int)->Int)->Int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// SET_TRUE: SPACE_AROUND_FUNCTION_TYPE_ARROW
|
||||||
@@ -139,6 +139,10 @@ public class JetFormatterTest extends AbstractJetFormatterTest {
|
|||||||
doTest();
|
doTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testFunctionalType() 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