KotlinLikeLangLineIndentProvider: fix options for parentheses

Part of #KT-22211
Part of #KT-39353
This commit is contained in:
Dmitry Gridin
2020-06-10 19:06:58 +07:00
parent 306abc79ed
commit 9d6ea3c073
10 changed files with 101 additions and 1 deletions
@@ -274,8 +274,14 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider
private fun isSimilarToFunctionInvocation(leftParenthesis: SemanticEditorPosition): Boolean = with(leftParenthesis.copy()) {
assert(isAt(LeftParenthesis))
moveBeforeIgnoringWhiteSpaceOrComment()
// `a()()()`
// ^
while (moveBeforeParenthesesIfPossible()) {
// loop
}
// calls with types e.g. `test<Int>()`
moveBeforeTypeParametersIfPossible()
@@ -93,6 +93,21 @@ public class PerformanceTypingIndentationTestGenerated extends AbstractPerforman
runTest("idea/testData/indentationOnNewline/FunctionBlock2.kt");
}
@TestMetadata("HigherOrderFunction.kt")
public void testHigherOrderFunction() throws Exception {
runTest("idea/testData/indentationOnNewline/HigherOrderFunction.kt");
}
@TestMetadata("HigherOrderFunction2.kt")
public void testHigherOrderFunction2() throws Exception {
runTest("idea/testData/indentationOnNewline/HigherOrderFunction2.kt");
}
@TestMetadata("HigherOrderFunction3.kt")
public void testHigherOrderFunction3() throws Exception {
runTest("idea/testData/indentationOnNewline/HigherOrderFunction3.kt");
}
@TestMetadata("InDelegationListAfterColon.kt")
public void testInDelegationListAfterColon() throws Exception {
runTest("idea/testData/indentationOnNewline/InDelegationListAfterColon.kt");
@@ -0,0 +1,9 @@
fun a(): () -> () -> Unit = { { } }
fun t() {
a()()(
<caret>
)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,7 @@
fun a(): () -> () -> Unit = { { } }
fun t() {
a()()(<caret>)
}
// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS
@@ -0,0 +1,9 @@
fun a(): () -> () -> Unit = { { } }
fun t() {
a()()(
<caret>
)
}
// SET_FALSE: ALIGN_MULTILINE_BINARY_OPERATION
@@ -0,0 +1,9 @@
fun a(): () -> () -> Unit = { { } }
fun t() {
a()()(
<caret>
)
}
// SET_FALSE: ALIGN_MULTILINE_BINARY_OPERATION
@@ -0,0 +1,7 @@
fun a(): () -> () -> Unit = { { } }
fun t() {
a()()(<caret>)
}
// SET_FALSE: ALIGN_MULTILINE_BINARY_OPERATION
@@ -0,0 +1,10 @@
fun a(): () -> () -> Unit = { { } }
fun t() {
a()()(
<caret>
)
}
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
@@ -0,0 +1,8 @@
fun a(): () -> () -> Unit = { { } }
fun t() {
a()()(<caret>)
}
// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS
// IGNORE_FORMATTER
@@ -95,6 +95,21 @@ public class TypingIndentationTestBaseGenerated extends AbstractTypingIndentatio
runTest("idea/testData/indentationOnNewline/FunctionBlock2.after.kt");
}
@TestMetadata("HigherOrderFunction.after.kt")
public void testHigherOrderFunction() throws Exception {
runTest("idea/testData/indentationOnNewline/HigherOrderFunction.after.kt");
}
@TestMetadata("HigherOrderFunction2.after.kt")
public void testHigherOrderFunction2() throws Exception {
runTest("idea/testData/indentationOnNewline/HigherOrderFunction2.after.kt");
}
@TestMetadata("HigherOrderFunction3.after.kt")
public void testHigherOrderFunction3() throws Exception {
runTest("idea/testData/indentationOnNewline/HigherOrderFunction3.after.kt");
}
@TestMetadata("InDelegationListAfterColon.after.kt")
public void testInDelegationListAfterColon() throws Exception {
runTest("idea/testData/indentationOnNewline/InDelegationListAfterColon.after.kt");
@@ -1157,6 +1172,11 @@ public class TypingIndentationTestBaseGenerated extends AbstractTypingIndentatio
runTest("idea/testData/indentationOnNewline/ArgumentListNormalIndent.after.inv.kt");
}
@TestMetadata("HigherOrderFunction2.after.inv.kt")
public void testHigherOrderFunction2() throws Exception {
runTest("idea/testData/indentationOnNewline/HigherOrderFunction2.after.inv.kt");
}
@TestMetadata("InDelegationListAfterColon.after.inv.kt")
public void testInDelegationListAfterColon() throws Exception {
runTest("idea/testData/indentationOnNewline/InDelegationListAfterColon.after.inv.kt");