Implement parenthesis wrapping options
This commit is contained in:
@@ -201,11 +201,9 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing
|
|||||||
|
|
||||||
after(LBRACKET).spaces(0)
|
after(LBRACKET).spaces(0)
|
||||||
before(RBRACKET).spaces(0)
|
before(RBRACKET).spaces(0)
|
||||||
after(LPAR).spaces(0)
|
|
||||||
before(RPAR).spaces(0)
|
|
||||||
|
|
||||||
afterInside(LPAR, VALUE_PARAMETER_LIST).spaces(0)
|
afterInside(LPAR, VALUE_PARAMETER_LIST).spaces(0, kotlinCommonSettings.METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE)
|
||||||
beforeInside(RPAR, VALUE_PARAMETER_LIST).spaces(0)
|
beforeInside(RPAR, VALUE_PARAMETER_LIST).spaces(0, kotlinCommonSettings.METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE)
|
||||||
afterInside(LT, TYPE_PARAMETER_LIST).spaces(0)
|
afterInside(LT, TYPE_PARAMETER_LIST).spaces(0)
|
||||||
beforeInside(GT, TYPE_PARAMETER_LIST).spaces(0)
|
beforeInside(GT, TYPE_PARAMETER_LIST).spaces(0)
|
||||||
afterInside(LPAR, VALUE_ARGUMENT_LIST).spaces(0)
|
afterInside(LPAR, VALUE_ARGUMENT_LIST).spaces(0)
|
||||||
@@ -214,6 +212,9 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing
|
|||||||
beforeInside(GT, TYPE_ARGUMENT_LIST).spaces(0)
|
beforeInside(GT, TYPE_ARGUMENT_LIST).spaces(0)
|
||||||
before(TYPE_ARGUMENT_LIST).spaces(0)
|
before(TYPE_ARGUMENT_LIST).spaces(0)
|
||||||
|
|
||||||
|
after(LPAR).spaces(0)
|
||||||
|
before(RPAR).spaces(0)
|
||||||
|
|
||||||
betweenInside(FOR_KEYWORD, LPAR, FOR).spaceIf(kotlinCommonSettings.SPACE_BEFORE_FOR_PARENTHESES)
|
betweenInside(FOR_KEYWORD, LPAR, FOR).spaceIf(kotlinCommonSettings.SPACE_BEFORE_FOR_PARENTHESES)
|
||||||
betweenInside(IF_KEYWORD, LPAR, IF).spaceIf(kotlinCommonSettings.SPACE_BEFORE_IF_PARENTHESES)
|
betweenInside(IF_KEYWORD, LPAR, IF).spaceIf(kotlinCommonSettings.SPACE_BEFORE_IF_PARENTHESES)
|
||||||
betweenInside(WHILE_KEYWORD, LPAR, WHILE).spaceIf(kotlinCommonSettings.SPACE_BEFORE_WHILE_PARENTHESES)
|
betweenInside(WHILE_KEYWORD, LPAR, WHILE).spaceIf(kotlinCommonSettings.SPACE_BEFORE_WHILE_PARENTHESES)
|
||||||
|
|||||||
+7
-1
@@ -46,6 +46,10 @@ class KotlinLanguageCodeStyleSettingsProvider : LanguageCodeStyleSettingsProvide
|
|||||||
try { return foo1(12, 13, 14)
|
try { return foo1(12, 13, 14)
|
||||||
} catch (e: Exception) { return 0 } finally { if (true) { return 1 } else { return 2 } } }
|
} catch (e: Exception) { return 0 } finally { if (true) { return 1 } else { return 2 } } }
|
||||||
private val f = {(a: Int)->a*2}
|
private val f = {(a: Int)->a*2}
|
||||||
|
|
||||||
|
fun longMethod(param1: Int,
|
||||||
|
param2: String) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class Enumeration {
|
enum class Enumeration {
|
||||||
@@ -198,7 +202,9 @@ class KotlinLanguageCodeStyleSettingsProvider : LanguageCodeStyleSettingsProvide
|
|||||||
"CATCH_ON_NEW_LINE",
|
"CATCH_ON_NEW_LINE",
|
||||||
"FINALLY_ON_NEW_LINE",
|
"FINALLY_ON_NEW_LINE",
|
||||||
"CALL_PARAMETERS_WRAP",
|
"CALL_PARAMETERS_WRAP",
|
||||||
"METHOD_PARAMETERS_WRAP"
|
"METHOD_PARAMETERS_WRAP",
|
||||||
|
"METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE",
|
||||||
|
"METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE"
|
||||||
)
|
)
|
||||||
consumer.renameStandardOption(CodeStyleSettingsCustomizable.WRAPPING_SWITCH_STATEMENT, "'when' statements")
|
consumer.renameStandardOption(CodeStyleSettingsCustomizable.WRAPPING_SWITCH_STATEMENT, "'when' statements")
|
||||||
consumer.showCustomOption(KotlinCodeStyleSettings::class.java, "ALIGN_IN_COLUMNS_CASE_BRANCH", "Align 'when' branches in columns",
|
consumer.showCustomOption(KotlinCodeStyleSettings::class.java, "ALIGN_IN_COLUMNS_CASE_BRANCH", "Align 'when' branches in columns",
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
fun foo(a: String,
|
||||||
|
b: String)
|
||||||
|
|
||||||
|
// SET_TRUE: METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
fun foo(
|
||||||
|
a: String,
|
||||||
|
b: String)
|
||||||
|
|
||||||
|
// SET_TRUE: METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
fun foo(a: String,
|
||||||
|
b: String)
|
||||||
|
|
||||||
|
// SET_TRUE: METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
fun foo(a: String,
|
||||||
|
b: String)
|
||||||
|
|
||||||
|
// SET_TRUE: METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
fun foo(a: String,
|
||||||
|
b: String
|
||||||
|
)
|
||||||
|
|
||||||
|
// SET_TRUE: METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
fun foo(a: String,
|
||||||
|
b: String)
|
||||||
|
|
||||||
|
// SET_TRUE: METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE
|
||||||
@@ -434,6 +434,18 @@ public class FormatterTestGenerated extends AbstractFormatterTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("MethodLParenthOnNextLine.after.kt")
|
||||||
|
public void testMethodLParenthOnNextLine() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/MethodLParenthOnNextLine.after.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("MethodRParenthOnNextLine.after.kt")
|
||||||
|
public void testMethodRParenthOnNextLine() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/MethodRParenthOnNextLine.after.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("Multideclaration.after.kt")
|
@TestMetadata("Multideclaration.after.kt")
|
||||||
public void testMultideclaration() throws Exception {
|
public void testMultideclaration() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/Multideclaration.after.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/Multideclaration.after.kt");
|
||||||
@@ -1094,6 +1106,18 @@ public class FormatterTestGenerated extends AbstractFormatterTest {
|
|||||||
doTestInverted(fileName);
|
doTestInverted(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("MethodLParenthOnNextLine.after.inv.kt")
|
||||||
|
public void testMethodLParenthOnNextLine() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/MethodLParenthOnNextLine.after.inv.kt");
|
||||||
|
doTestInverted(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("MethodRParenthOnNextLine.after.inv.kt")
|
||||||
|
public void testMethodRParenthOnNextLine() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/MethodRParenthOnNextLine.after.inv.kt");
|
||||||
|
doTestInverted(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("MultilineFunctionLiteralWithParams.after.inv.kt")
|
@TestMetadata("MultilineFunctionLiteralWithParams.after.inv.kt")
|
||||||
public void testMultilineFunctionLiteralWithParams() throws Exception {
|
public void testMultilineFunctionLiteralWithParams() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/MultilineFunctionLiteralWithParams.after.inv.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/MultilineFunctionLiteralWithParams.after.inv.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user