diff --git a/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTabsInMethodParameters.after.kt b/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTabsInMethodParameters.after.kt index 0046209e1e13..5509b569f61b 100644 --- a/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTabsInMethodParameters.after.kt +++ b/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTabsInMethodParameters.after.kt @@ -1,6 +1,5 @@ // SET_TRUE: SMART_TABS // SET_TRUE: USE_TAB_CHARACTER -// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER fun method( arg1: String, diff --git a/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTabsInMethodParameters.kt b/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTabsInMethodParameters.kt index 885aca0c1770..440c7268bcdf 100644 --- a/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTabsInMethodParameters.kt +++ b/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTabsInMethodParameters.kt @@ -1,6 +1,5 @@ // SET_TRUE: SMART_TABS // SET_TRUE: USE_TAB_CHARACTER -// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER fun method( arg1: String, diff --git a/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTabsOnConstructorParameters.after.kt b/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTabsOnConstructorParameters.after.kt index f1979573ffb2..b5b58af31d04 100644 --- a/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTabsOnConstructorParameters.after.kt +++ b/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTabsOnConstructorParameters.after.kt @@ -1,8 +1,7 @@ // SET_TRUE: SMART_TABS // SET_TRUE: USE_TAB_CHARACTER -// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER class A( - a: Int, - + a: Int, + ) diff --git a/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTabsOnConstructorParameters.kt b/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTabsOnConstructorParameters.kt index 7523d5903129..d9a665cbd55d 100644 --- a/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTabsOnConstructorParameters.kt +++ b/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTabsOnConstructorParameters.kt @@ -1,7 +1,6 @@ // SET_TRUE: SMART_TABS // SET_TRUE: USE_TAB_CHARACTER -// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER class A( - a: Int, + a: Int, ) diff --git a/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTabsOnConstructorParametersWithInvertedAlignWhenMultiline.after.kt b/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTabsOnConstructorParametersWithInvertedAlignWhenMultiline.after.kt index 98c1f37c3272..b9852311d784 100644 --- a/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTabsOnConstructorParametersWithInvertedAlignWhenMultiline.after.kt +++ b/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTabsOnConstructorParametersWithInvertedAlignWhenMultiline.after.kt @@ -1,7 +1,6 @@ // SET_TRUE: SMART_TABS // SET_TRUE: USE_TAB_CHARACTER // SET_TRUE: ALIGN_MULTILINE_PARAMETERS -// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER class A( a: Int, diff --git a/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTabsOnConstructorParametersWithInvertedAlignWhenMultiline.kt b/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTabsOnConstructorParametersWithInvertedAlignWhenMultiline.kt index cc05ddb59977..e3aa7d6a5019 100644 --- a/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTabsOnConstructorParametersWithInvertedAlignWhenMultiline.kt +++ b/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTabsOnConstructorParametersWithInvertedAlignWhenMultiline.kt @@ -1,7 +1,6 @@ // SET_TRUE: SMART_TABS // SET_TRUE: USE_TAB_CHARACTER // SET_TRUE: ALIGN_MULTILINE_PARAMETERS -// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER class A( a: Int, diff --git a/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTrailingCommaAndWhitespaceBeforeLineBreak.after.kt b/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTrailingCommaAndWhitespaceBeforeLineBreak.after.kt index 3a921ff30f14..8013429ee65f 100644 --- a/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTrailingCommaAndWhitespaceBeforeLineBreak.after.kt +++ b/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTrailingCommaAndWhitespaceBeforeLineBreak.after.kt @@ -1,5 +1,4 @@ // SET_TRUE: SMART_TABS -// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER fun method( arg1: String, diff --git a/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTrailingCommaAndWhitespaceBeforeLineBreak.kt b/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTrailingCommaAndWhitespaceBeforeLineBreak.kt index eb4c4a501ec6..3c1754d3edac 100644 --- a/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTrailingCommaAndWhitespaceBeforeLineBreak.kt +++ b/plugins/kotlin/idea/tests/testData/editor/enterHandler/SmartEnterWithTrailingCommaAndWhitespaceBeforeLineBreak.kt @@ -1,5 +1,4 @@ // SET_TRUE: SMART_TABS -// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER fun method( arg1: String, diff --git a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration.after.inv.kt b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration.after.inv.kt index 92b3ca0c50b0..2a56b7f78980 100644 --- a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration.after.inv.kt +++ b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration.after.inv.kt @@ -1,7 +1,8 @@ fun a() { val ( - + ) } -// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS \ No newline at end of file +// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS +// IGNORE_FORMATTER \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration.after.kt b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration.after.kt index 92b3ca0c50b0..2a56b7f78980 100644 --- a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration.after.kt +++ b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration.after.kt @@ -1,7 +1,8 @@ fun a() { val ( - + ) } -// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS \ No newline at end of file +// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS +// IGNORE_FORMATTER \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration.kt b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration.kt index c18fb03db29b..949ba11ed050 100644 --- a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration.kt +++ b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration.kt @@ -2,4 +2,5 @@ fun a() { val () } -// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS \ No newline at end of file +// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS +// IGNORE_FORMATTER \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration2.after.inv.kt b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration2.after.inv.kt index 988fb887de63..1db7a3858464 100644 --- a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration2.after.inv.kt +++ b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration2.after.inv.kt @@ -1,7 +1,8 @@ fun a() { var ( - + ) } -// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS \ No newline at end of file +// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS +// IGNORE_FORMATTER \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration2.after.kt b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration2.after.kt index 988fb887de63..1db7a3858464 100644 --- a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration2.after.kt +++ b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration2.after.kt @@ -1,7 +1,8 @@ fun a() { var ( - + ) } -// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS \ No newline at end of file +// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS +// IGNORE_FORMATTER \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration2.kt b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration2.kt index 120a356ad7ae..07a6499f746f 100644 --- a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration2.kt +++ b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration2.kt @@ -2,4 +2,5 @@ fun a() { var () } -// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS \ No newline at end of file +// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS +// IGNORE_FORMATTER \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration3.after.inv.kt b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration3.after.inv.kt index 360d8816df1e..a8df379a4eda 100644 --- a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration3.after.inv.kt +++ b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration3.after.inv.kt @@ -1,8 +1,9 @@ fun a() { a.forEach { ( - + )} } // SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS // SET_FALSE: ALIGN_MULTILINE_BINARY_OPERATION +// IGNORE_FORMATTER diff --git a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration3.after.kt b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration3.after.kt index 37c9641aff19..a8df379a4eda 100644 --- a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration3.after.kt +++ b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration3.after.kt @@ -1,8 +1,9 @@ fun a() { a.forEach { ( - + )} } // SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS // SET_FALSE: ALIGN_MULTILINE_BINARY_OPERATION +// IGNORE_FORMATTER diff --git a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration3.kt b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration3.kt index 222a1ac8d1d8..3748b7241e94 100644 --- a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration3.kt +++ b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInDestructuringDeclaration3.kt @@ -4,3 +4,4 @@ fun a() { // SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS // SET_FALSE: ALIGN_MULTILINE_BINARY_OPERATION +// IGNORE_FORMATTER diff --git a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInGetter.after.kt b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInGetter.after.kt index 1367515c0263..a251855083fc 100644 --- a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInGetter.after.kt +++ b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInGetter.after.kt @@ -1,8 +1,8 @@ class Test { val a: Boolean get( - + ) } // SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS -// KT-39444 \ No newline at end of file +// IGNORE_FORMATTER \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInGetter.kt b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInGetter.kt index dd49e5677b8f..db3f66f8ff7f 100644 --- a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInGetter.kt +++ b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInGetter.kt @@ -3,4 +3,4 @@ class Test { } // SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS -// KT-39444 \ No newline at end of file +// IGNORE_FORMATTER \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInGetter2.after.kt b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInGetter2.after.kt index 8c645f86d795..e57d61190aa4 100644 --- a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInGetter2.after.kt +++ b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInGetter2.after.kt @@ -1,9 +1,8 @@ class Test { val a: Boolean get( - + ) } // SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS -// IGNORE_FORMATTER -// KT-39444 \ No newline at end of file +// IGNORE_FORMATTER \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInGetter2.kt b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInGetter2.kt index 1ef654d17622..cbec8601ff4b 100644 --- a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInGetter2.kt +++ b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInGetter2.kt @@ -3,5 +3,4 @@ class Test { } // SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS -// IGNORE_FORMATTER -// KT-39444 \ No newline at end of file +// IGNORE_FORMATTER \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInSetter.after.kt b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInSetter.after.kt index db693957e99c..e31ab72c5cb2 100644 --- a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInSetter.after.kt +++ b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInSetter.after.kt @@ -2,8 +2,9 @@ class Test { var a: Boolean get() = false set( - + ) } -// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS \ No newline at end of file +// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS +// IGNORE_FORMATTER \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInSetter.kt b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInSetter.kt index a856508dd398..309e334cf186 100644 --- a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInSetter.kt +++ b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInSetter.kt @@ -4,4 +4,5 @@ class Test { set() } -// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS \ No newline at end of file +// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS +// IGNORE_FORMATTER \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInSetter2.after.kt b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInSetter2.after.kt index c4efd863220b..b7db7f450559 100644 --- a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInSetter2.after.kt +++ b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParameters/EmptyParameterInSetter2.after.kt @@ -2,7 +2,7 @@ class Test { var a: Boolean get() = false set( - + ) } diff --git a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParenthesisInBinaryExpression/InExpressionsParentheses.after.kt b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParenthesisInBinaryExpression/InExpressionsParentheses.after.kt index f4e8d6576d12..681396c9fef1 100644 --- a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParenthesisInBinaryExpression/InExpressionsParentheses.after.kt +++ b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParenthesisInBinaryExpression/InExpressionsParentheses.after.kt @@ -1,5 +1,5 @@ val somelong = 3 + 4 - ( - + ) // SET_TRUE: ALIGN_MULTILINE_BINARY_OPERATION diff --git a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParenthesisInBinaryExpression/InExpressionsParentheses4.after.kt b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParenthesisInBinaryExpression/InExpressionsParentheses4.after.kt index e5a9d4e8501a..4dfb0932e5dd 100644 --- a/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParenthesisInBinaryExpression/InExpressionsParentheses4.after.kt +++ b/plugins/kotlin/idea/tests/testData/editor/enterHandler/emptyParenthesisInBinaryExpression/InExpressionsParentheses4.after.kt @@ -1,6 +1,6 @@ fun a() { val somelong = 3 + 4 - ( - + ) } diff --git a/plugins/kotlin/line-indent-provider/src/org/jetbrains/kotlin/idea/formatter/lineIndent/KotlinLangLineIndentProvider.kt b/plugins/kotlin/line-indent-provider/src/org/jetbrains/kotlin/idea/formatter/lineIndent/KotlinLangLineIndentProvider.kt index 0042e9bbd4a4..a9234262a2db 100644 --- a/plugins/kotlin/line-indent-provider/src/org/jetbrains/kotlin/idea/formatter/lineIndent/KotlinLangLineIndentProvider.kt +++ b/plugins/kotlin/line-indent-provider/src/org/jetbrains/kotlin/idea/formatter/lineIndent/KotlinLangLineIndentProvider.kt @@ -253,72 +253,70 @@ abstract class KotlinLangLineIndentProvider : JavaLikeLangLineIndentProvider() { val leftParenthesis = currentPosition.findLeftParenthesisBackwardsSkippingNested(LeftParenthesis, RightParenthesis) if (!leftParenthesis.isAt(LeftParenthesis)) return null - // case only for caret before [RightParenthesis] - if (!currentPosition.hasLineBreaksAfter(offset)) { - fun createIndent( - isParameterList: Boolean, - baseLineOffset: Int, - ): IndentCalculator { - val indent = if (before.isAt(Comma)) { - when { - isParameterList && settings.alignMultilineParameters || - !isParameterList && settings.alignMultilineParametersInCalls -> { - val firstElement = leftParenthesis.afterIgnoringWhiteSpaceOrComment() - return createIndentCalculator(createAlignMultilineIndent(firstElement), firstElement.startOffset) - } - - isParameterList && settings.continuationIndentInParameterLists || - !isParameterList && settings.continuationIndentInArgumentLists -> Indent.getContinuationIndent() - - else -> Indent.getNormalIndent() + val hasLineBreaksAfter = currentPosition.hasLineBreaksAfter(offset) + fun createIndent( + isParameterList: Boolean, + baseLineOffset: Int, + ): IndentCalculator { + val indent = if (before.isAt(Comma) || hasLineBreaksAfter) { + val firstElement = leftParenthesis.afterIgnoringWhiteSpaceOrComment() + when { + !firstElement.isAt(RightParenthesis) && ( + isParameterList && settings.alignMultilineParameters || + !isParameterList && settings.alignMultilineParametersInCalls + ) -> { + return createIndentCalculator(createAlignMultilineIndent(firstElement), firstElement.startOffset) } - } else { - if (settings.alignWhenMultilineFunctionParentheses) - createAlignMultilineIndent(leftParenthesis) - else - Indent.getNoneIndent() + + isParameterList && settings.continuationIndentInParameterLists || + !isParameterList && settings.continuationIndentInArgumentLists -> Indent.getContinuationIndent() + + else -> Indent.getNormalIndent() } - - return createIndentCalculator(indent, baseLineOffset) - } - - findFunctionKeywordBeforeIdentifier(leftParenthesis.beforeIgnoringWhiteSpaceOrComment())?.let { - return createIndent(isParameterList = true, it.startOffset) - } - - // NB: this covered [KtTokens.CONSTRUCTOR_KEYWORD], [KtTokens.SET_KEYWORD], [KtTokens.GET_KEYWORD], [KtTokens.INIT_KEYWORD] as well - if (isSimilarToFunctionInvocation(leftParenthesis)) { - return createIndent(isParameterList = false, leftParenthesis.startOffset) - } - - if (isDestructuringDeclaration(leftParenthesis, rightParenthesis)) { - return createIndentCalculator( - if (before.isAt(Comma)) Indent.getNormalIndent() else Indent.getNoneIndent(), - leftParenthesis.startOffset - ) - } - - leftParenthesis.beforeIgnoringWhiteSpaceOrComment().let { keyword -> - val indent = when { - keyword.isAt(IfKeyword) && !before.isAt(LeftParenthesis) -> - if (settings.continuationIndentInIfCondition) Indent.getContinuationIndent() else Indent.getNormalIndent() - - keyword.isControlFlowKeyword() -> Indent.getNoneIndent() - else -> null - } - - indent?.let { return createIndentCalculator(it, keyword.startOffset) } - } - - return if (settings.alignWhenMultilineBinaryExpression) { - val anchor = if (before.isAt(LeftParenthesis)) leftParenthesis else leftParenthesis.afterIgnoringWhiteSpaceOrComment() - createIndentCalculator(createAlignMultilineIndent(anchor), anchor.startOffset) } else { - createIndentCalculator(Indent.getContinuationIndent(), leftParenthesis.startOffset) + if (settings.alignWhenMultilineFunctionParentheses) + createAlignMultilineIndent(leftParenthesis) + else + Indent.getNoneIndent() } + + return createIndentCalculator(indent, baseLineOffset) } - return null + findFunctionKeywordBeforeIdentifier(leftParenthesis.beforeIgnoringWhiteSpaceOrComment())?.let { + return createIndent(isParameterList = true, it.startOffset) + } + + // NB: this covered [KtTokens.CONSTRUCTOR_KEYWORD], [KtTokens.SET_KEYWORD], [KtTokens.GET_KEYWORD], [KtTokens.INIT_KEYWORD] as well + if (isSimilarToFunctionInvocation(leftParenthesis)) { + return createIndent(isParameterList = false, leftParenthesis.startOffset) + } + + if (isDestructuringDeclaration(leftParenthesis, rightParenthesis)) { + return createIndentCalculator( + if (before.isAt(Comma) || hasLineBreaksAfter) Indent.getNormalIndent() else Indent.getNoneIndent(), + leftParenthesis.startOffset + ) + } + + leftParenthesis.beforeIgnoringWhiteSpaceOrComment().let { keyword -> + val indent = when { + keyword.isAt(IfKeyword) && !before.isAt(LeftParenthesis) -> + if (settings.continuationIndentInIfCondition) Indent.getContinuationIndent() else Indent.getNormalIndent() + + keyword.isControlFlowKeyword() -> if (hasLineBreaksAfter) Indent.getNormalIndent() else Indent.getNoneIndent() + else -> null + } + + indent?.let { return createIndentCalculator(it, keyword.startOffset) } + } + + return if (settings.alignWhenMultilineBinaryExpression && !hasLineBreaksAfter) { + val anchor = if (before.isAt(LeftParenthesis)) leftParenthesis else leftParenthesis.afterIgnoringWhiteSpaceOrComment() + createIndentCalculator(createAlignMultilineIndent(anchor), anchor.startOffset) + } else { + createIndentCalculator(Indent.getContinuationIndent(), leftParenthesis.startOffset) + } } /**