diff --git a/idea/line-indent-provider/src/org/jetbrains/kotlin/idea/formatter/lineIndent/KotlinLikeLangLineIndentProvider.kt b/idea/line-indent-provider/src/org/jetbrains/kotlin/idea/formatter/lineIndent/KotlinLikeLangLineIndentProvider.kt index af1847aa8e4..dde721e03a0 100644 --- a/idea/line-indent-provider/src/org/jetbrains/kotlin/idea/formatter/lineIndent/KotlinLikeLangLineIndentProvider.kt +++ b/idea/line-indent-provider/src/org/jetbrains/kotlin/idea/formatter/lineIndent/KotlinLikeLangLineIndentProvider.kt @@ -43,12 +43,25 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider val before = currentPosition.beforeOptionalMix(*WHITE_SPACE_OR_COMMENT_BIT_SET) val after = currentPosition.afterOptionalMix(*WHITE_SPACE_OR_COMMENT_BIT_SET) - when { - before.isAt(BlockOpeningBrace) && after.isAt(BlockClosingBrace) && !currentPosition.hasLineBreaksAfter(offset) -> - return factory.createIndentCalculator(Indent.getNoneIndent(), before.startOffset) - before.isAt(ArrayOpeningBracket) && after.isAt(ArrayClosingBracket) && !currentPosition.hasLineBreaksAfter(offset) -> - return factory.createIndentCalculator(Indent.getNoneIndent(), before.startOffset) + when { + after.isAt(BlockClosingBrace) && !currentPosition.hasLineBreaksAfter(offset) -> + return factory.createIndentCalculatorForBrace(before, after, BlockOpeningBrace, BlockClosingBrace) + + before.isAt(BlockOpeningBrace) && after.isAt(BlockClosingBrace) -> + return factory.createIndentCalculator(Indent.getNormalIndent(), before.startOffset) + + after.isAt(ArrayClosingBracket) && !currentPosition.hasLineBreaksAfter(offset) -> + return factory.createIndentCalculatorForBrace(before, after, ArrayOpeningBracket, ArrayClosingBracket) + + before.isAt(ArrayOpeningBracket) && after.isAt(ArrayClosingBracket) -> { + val indent = if (isSimilarToFunctionInvocation(before)) + Indent.getContinuationIndent() + else + Indent.getNormalIndent() + + return factory.createIndentCalculator(indent, before.startOffset) + } before.isAt(BlockOpeningBrace) && before.beforeIgnoringWhiteSpaceOrComment().isFunctionDeclaration() -> return factory.createIndentCalculator(Indent.getNormalIndent(), before.startOffset) @@ -115,6 +128,24 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider } } + private fun IndentCalculatorFactory.createIndentCalculatorForBrace( + before: SemanticEditorPosition, + after: SemanticEditorPosition, + leftBraceType: SemanticEditorPosition.SyntaxElement, + rightBraceType: SemanticEditorPosition.SyntaxElement + ): IndentCalculator? { + val leftBrace = before.copyAnd { + it.moveToLeftParenthesisBackwardsSkippingNested(leftBraceType, rightBraceType) + } + + val indent = if (after.after().afterOptionalMix(*WHITE_SPACE_OR_COMMENT_BIT_SET).isAt(Comma)) + createAlignMultilineIndent(leftBrace) + else + Indent.getNoneIndent() + + return createIndentCalculator(indent, leftBrace.startOffset) + } + private fun IndentCalculatorFactory.createIndentCalculatorForParenthesis( leftParenthesis: SemanticEditorPosition, currentPosition: SemanticEditorPosition, @@ -272,20 +303,21 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider } } + /** + * @param leftParenthesis is `(` or `[` + */ private fun isSimilarToFunctionInvocation(leftParenthesis: SemanticEditorPosition): Boolean = with(leftParenthesis.copy()) { - assert(isAt(LeftParenthesis)) - moveBeforeIgnoringWhiteSpaceOrComment() + moveBefore() - // `a()()()` - // ^ - while (moveBeforeParenthesesIfPossible()) { - // loop - } + if (!moveBeforeWhileThisIsWhiteSpaceOnSameLineOrBlockComment() || isAtEnd) return false // calls with types e.g. `test()` - moveBeforeTypeParametersIfPossible() + if (isAt(CloseTypeBrace)) { + moveBeforeParentheses(OpenTypeBrace, CloseTypeBrace) + return moveBeforeWhileThisIsWhiteSpaceOnSameLineOrBlockComment() && isIdentifier() + } - return isAt(Identifier) || isAt(KtTokens.THIS_KEYWORD) + return isIdentifier() || isAtAnyOf(RightParenthesis, ArrayClosingBracket) } private fun isDestructuringDeclaration( @@ -448,6 +480,8 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider } } + private fun SemanticEditorPosition.isIdentifier(): Boolean = isAt(Identifier) || isAt(KtTokens.THIS_KEYWORD) + private fun SemanticEditorPosition.isVarOrVal(): Boolean = isAtAnyOf(Var, Val) private fun SemanticEditorPosition.moveBeforeBlockIfPossible(): Boolean = moveBeforeParenthesesIfPossible( @@ -478,6 +512,16 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider private fun SemanticEditorPosition.moveBeforeWhileThisIsWhiteSpaceOrComment() = moveBeforeOptionalMix(*WHITE_SPACE_OR_COMMENT_BIT_SET) + private fun SemanticEditorPosition.moveBeforeWhileThisIsWhiteSpaceOnSameLineOrBlockComment(): Boolean { + while (!isAtEnd) { + if (isAt(Whitespace) && isAtMultiline) return false + if (!isAt(BlockComment)) break + moveBefore() + } + + return true + } + private fun SemanticEditorPosition.moveBeforeIgnoringWhiteSpaceOrComment() { moveBefore() moveBeforeWhileThisIsWhiteSpaceOrComment() diff --git a/idea/performanceTests/test/org/jetbrains/kotlin/idea/perf/PerformanceTypingIndentationTestGenerated.java b/idea/performanceTests/test/org/jetbrains/kotlin/idea/perf/PerformanceTypingIndentationTestGenerated.java index 60234463b25..3291fdd4e0a 100644 --- a/idea/performanceTests/test/org/jetbrains/kotlin/idea/perf/PerformanceTypingIndentationTestGenerated.java +++ b/idea/performanceTests/test/org/jetbrains/kotlin/idea/perf/PerformanceTypingIndentationTestGenerated.java @@ -183,11 +183,36 @@ public class PerformanceTypingIndentationTestGenerated extends AbstractPerforman runTest("idea/testData/indentationOnNewline/KT20783.kt"); } + @TestMetadata("LambdaInArguments.kt") + public void testLambdaInArguments() throws Exception { + runTest("idea/testData/indentationOnNewline/LambdaInArguments.kt"); + } + + @TestMetadata("LambdaInArguments2.kt") + public void testLambdaInArguments2() throws Exception { + runTest("idea/testData/indentationOnNewline/LambdaInArguments2.kt"); + } + @TestMetadata("LargeFile.kt") public void testLargeFile() throws Exception { runTest("idea/testData/indentationOnNewline/LargeFile.kt"); } + @TestMetadata("LiteralExpression.kt") + public void testLiteralExpression() throws Exception { + runTest("idea/testData/indentationOnNewline/LiteralExpression.kt"); + } + + @TestMetadata("LiteralExpression2.kt") + public void testLiteralExpression2() throws Exception { + runTest("idea/testData/indentationOnNewline/LiteralExpression2.kt"); + } + + @TestMetadata("LiteralExpression3.kt") + public void testLiteralExpression3() throws Exception { + runTest("idea/testData/indentationOnNewline/LiteralExpression3.kt"); + } + @TestMetadata("ModifierListInUnfinishedDeclaration.kt") public void testModifierListInUnfinishedDeclaration() throws Exception { runTest("idea/testData/indentationOnNewline/ModifierListInUnfinishedDeclaration.kt"); @@ -544,6 +569,26 @@ public class PerformanceTypingIndentationTestGenerated extends AbstractPerforman KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/indentationOnNewline/emptyParameters"), Pattern.compile("^([^.]+)\\.(kt|kts)$"), null, true); } + @TestMetadata("EmptyArgumentInCallByArrayAccess.kt") + public void testEmptyArgumentInCallByArrayAccess() throws Exception { + runTest("idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByArrayAccess.kt"); + } + + @TestMetadata("EmptyArgumentInCallByArrayAccess2.kt") + public void testEmptyArgumentInCallByArrayAccess2() throws Exception { + runTest("idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByArrayAccess2.kt"); + } + + @TestMetadata("EmptyArgumentInCallByDeclaration.kt") + public void testEmptyArgumentInCallByDeclaration() throws Exception { + runTest("idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByDeclaration.kt"); + } + + @TestMetadata("EmptyArgumentInCallByDeclaration2.kt") + public void testEmptyArgumentInCallByDeclaration2() throws Exception { + runTest("idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByDeclaration2.kt"); + } + @TestMetadata("EmptyArgumentInCallByReference.kt") public void testEmptyArgumentInCallByReference() throws Exception { runTest("idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByReference.kt"); @@ -832,6 +877,16 @@ public class PerformanceTypingIndentationTestGenerated extends AbstractPerforman runTest("idea/testData/indentationOnNewline/emptyParenthesisInBinaryExpression/BinaryWithTypeExpressions.kt"); } + @TestMetadata("EmptyArgumentInCallByArrayAccess.kt") + public void testEmptyArgumentInCallByArrayAccess() throws Exception { + runTest("idea/testData/indentationOnNewline/emptyParenthesisInBinaryExpression/EmptyArgumentInCallByArrayAccess.kt"); + } + + @TestMetadata("EmptyArgumentInCallByDeclaration.kt") + public void testEmptyArgumentInCallByDeclaration() throws Exception { + runTest("idea/testData/indentationOnNewline/emptyParenthesisInBinaryExpression/EmptyArgumentInCallByDeclaration.kt"); + } + @TestMetadata("InBinaryExpressionInMiddle.kt") public void testInBinaryExpressionInMiddle() throws Exception { runTest("idea/testData/indentationOnNewline/emptyParenthesisInBinaryExpression/InBinaryExpressionInMiddle.kt"); diff --git a/idea/testData/indentationOnNewline/InLabmdaAfterArrow.after.kt b/idea/testData/indentationOnNewline/InLabmdaAfterArrow.after.kt index 0bdeb1f59e9..3cd88f1f046 100644 --- a/idea/testData/indentationOnNewline/InLabmdaAfterArrow.after.kt +++ b/idea/testData/indentationOnNewline/InLabmdaAfterArrow.after.kt @@ -1,5 +1,3 @@ val a: (String) -> String = { some -> } - -// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER \ No newline at end of file diff --git a/idea/testData/indentationOnNewline/InLabmdaAfterArrow.kt b/idea/testData/indentationOnNewline/InLabmdaAfterArrow.kt index f157dc0258e..bdc540895c5 100644 --- a/idea/testData/indentationOnNewline/InLabmdaAfterArrow.kt +++ b/idea/testData/indentationOnNewline/InLabmdaAfterArrow.kt @@ -1,3 +1 @@ val a: (String) -> String = { some ->} - -// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER \ No newline at end of file diff --git a/idea/testData/indentationOnNewline/InLambdaAfterArrowWithSpaces.after.kt b/idea/testData/indentationOnNewline/InLambdaAfterArrowWithSpaces.after.kt index 0bdeb1f59e9..3cd88f1f046 100644 --- a/idea/testData/indentationOnNewline/InLambdaAfterArrowWithSpaces.after.kt +++ b/idea/testData/indentationOnNewline/InLambdaAfterArrowWithSpaces.after.kt @@ -1,5 +1,3 @@ val a: (String) -> String = { some -> } - -// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER \ No newline at end of file diff --git a/idea/testData/indentationOnNewline/InLambdaAfterArrowWithSpaces.kt b/idea/testData/indentationOnNewline/InLambdaAfterArrowWithSpaces.kt index 590cac0296f..134a0f3984c 100644 --- a/idea/testData/indentationOnNewline/InLambdaAfterArrowWithSpaces.kt +++ b/idea/testData/indentationOnNewline/InLambdaAfterArrowWithSpaces.kt @@ -1,3 +1 @@ val a: (String) -> String = { some -> } - -// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER \ No newline at end of file diff --git a/idea/testData/indentationOnNewline/LambdaInArguments.after.kt b/idea/testData/indentationOnNewline/LambdaInArguments.after.kt new file mode 100644 index 00000000000..cf319fd3750 --- /dev/null +++ b/idea/testData/indentationOnNewline/LambdaInArguments.after.kt @@ -0,0 +1,9 @@ +fun a() { + b({1 + }, + {}, + {}, + ) +} + +// IGNORE_FORMATTER \ No newline at end of file diff --git a/idea/testData/indentationOnNewline/LambdaInArguments.kt b/idea/testData/indentationOnNewline/LambdaInArguments.kt new file mode 100644 index 00000000000..6835b06364c --- /dev/null +++ b/idea/testData/indentationOnNewline/LambdaInArguments.kt @@ -0,0 +1,8 @@ +fun a() { + b({1}, + {}, + {}, + ) +} + +// IGNORE_FORMATTER \ No newline at end of file diff --git a/idea/testData/indentationOnNewline/LambdaInArguments2.after.kt b/idea/testData/indentationOnNewline/LambdaInArguments2.after.kt new file mode 100644 index 00000000000..a2de97f4e43 --- /dev/null +++ b/idea/testData/indentationOnNewline/LambdaInArguments2.after.kt @@ -0,0 +1,10 @@ +fun a() { + b({ + 1 + }, + {}, + {}, + ) +} + +// IGNORE_FORMATTER \ No newline at end of file diff --git a/idea/testData/indentationOnNewline/LambdaInArguments2.kt b/idea/testData/indentationOnNewline/LambdaInArguments2.kt new file mode 100644 index 00000000000..e513c389feb --- /dev/null +++ b/idea/testData/indentationOnNewline/LambdaInArguments2.kt @@ -0,0 +1,9 @@ +fun a() { + b({ + 1}, + {}, + {}, + ) +} + +// IGNORE_FORMATTER \ No newline at end of file diff --git a/idea/testData/indentationOnNewline/LiteralExpression.after.kt b/idea/testData/indentationOnNewline/LiteralExpression.after.kt new file mode 100644 index 00000000000..0dff42057cc --- /dev/null +++ b/idea/testData/indentationOnNewline/LiteralExpression.after.kt @@ -0,0 +1,8 @@ +@Anno([ + 1 + ], + [2], +) +class A + +// IGNORE_FORMATTER \ No newline at end of file diff --git a/idea/testData/indentationOnNewline/LiteralExpression.kt b/idea/testData/indentationOnNewline/LiteralExpression.kt new file mode 100644 index 00000000000..3afb53ef29f --- /dev/null +++ b/idea/testData/indentationOnNewline/LiteralExpression.kt @@ -0,0 +1,7 @@ +@Anno([ + 1], + [2], +) +class A + +// IGNORE_FORMATTER \ No newline at end of file diff --git a/idea/testData/indentationOnNewline/LiteralExpression2.after.kt b/idea/testData/indentationOnNewline/LiteralExpression2.after.kt new file mode 100644 index 00000000000..77a7f54ceb2 --- /dev/null +++ b/idea/testData/indentationOnNewline/LiteralExpression2.after.kt @@ -0,0 +1,7 @@ +@Anno([1 + ], + [2], +) +class A + +// IGNORE_FORMATTER \ No newline at end of file diff --git a/idea/testData/indentationOnNewline/LiteralExpression2.kt b/idea/testData/indentationOnNewline/LiteralExpression2.kt new file mode 100644 index 00000000000..c71d82be1c9 --- /dev/null +++ b/idea/testData/indentationOnNewline/LiteralExpression2.kt @@ -0,0 +1,6 @@ +@Anno([1], + [2], +) +class A + +// IGNORE_FORMATTER \ No newline at end of file diff --git a/idea/testData/indentationOnNewline/LiteralExpression3.after.kt b/idea/testData/indentationOnNewline/LiteralExpression3.after.kt new file mode 100644 index 00000000000..e5a55687428 --- /dev/null +++ b/idea/testData/indentationOnNewline/LiteralExpression3.after.kt @@ -0,0 +1,8 @@ +@Anno([ + + ], + [2], +) +class A + +// IGNORE_FORMATTER \ No newline at end of file diff --git a/idea/testData/indentationOnNewline/LiteralExpression3.kt b/idea/testData/indentationOnNewline/LiteralExpression3.kt new file mode 100644 index 00000000000..08fd66f77bc --- /dev/null +++ b/idea/testData/indentationOnNewline/LiteralExpression3.kt @@ -0,0 +1,6 @@ +@Anno([], + [2], +) +class A + +// IGNORE_FORMATTER \ No newline at end of file diff --git a/idea/testData/indentationOnNewline/arrayAccess/listAccess.after.kt b/idea/testData/indentationOnNewline/arrayAccess/listAccess.after.kt index 7b440c75065..43cb8644bc1 100644 --- a/idea/testData/indentationOnNewline/arrayAccess/listAccess.after.kt +++ b/idea/testData/indentationOnNewline/arrayAccess/listAccess.after.kt @@ -2,7 +2,9 @@ fun a() { val a = listOf(1, 2) println( a[ - + ] ) } + +// IGNORE_FORMATTER \ No newline at end of file diff --git a/idea/testData/indentationOnNewline/arrayAccess/listAccess.kt b/idea/testData/indentationOnNewline/arrayAccess/listAccess.kt index 411fd3074b0..9c88f80cede 100644 --- a/idea/testData/indentationOnNewline/arrayAccess/listAccess.kt +++ b/idea/testData/indentationOnNewline/arrayAccess/listAccess.kt @@ -4,3 +4,5 @@ fun a() { a[] ) } + +// IGNORE_FORMATTER \ No newline at end of file diff --git a/idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByArrayAccess.after.kt b/idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByArrayAccess.after.kt new file mode 100644 index 00000000000..4877d98b96d --- /dev/null +++ b/idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByArrayAccess.after.kt @@ -0,0 +1,8 @@ +fun a() { + val b = listOf(fun(c: Int) {}) + b[0]( + + ) +} + +// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS \ No newline at end of file diff --git a/idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByArrayAccess.kt b/idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByArrayAccess.kt new file mode 100644 index 00000000000..f6345669fea --- /dev/null +++ b/idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByArrayAccess.kt @@ -0,0 +1,6 @@ +fun a() { + val b = listOf(fun(c: Int) {}) + b[0]() +} + +// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS \ No newline at end of file diff --git a/idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByArrayAccess2.after.kt b/idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByArrayAccess2.after.kt new file mode 100644 index 00000000000..2e93ec6a396 --- /dev/null +++ b/idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByArrayAccess2.after.kt @@ -0,0 +1,9 @@ +fun a() { + val b = listOf(fun(c: Int) {}) + b[0]( + + ) +} + +// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS +// IGNORE_FORMATTER \ No newline at end of file diff --git a/idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByArrayAccess2.kt b/idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByArrayAccess2.kt new file mode 100644 index 00000000000..31d1b47719e --- /dev/null +++ b/idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByArrayAccess2.kt @@ -0,0 +1,7 @@ +fun a() { + val b = listOf(fun(c: Int) {}) + b[0]() +} + +// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS +// IGNORE_FORMATTER \ No newline at end of file diff --git a/idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByDeclaration.after.kt b/idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByDeclaration.after.kt new file mode 100644 index 00000000000..165722d7b51 --- /dev/null +++ b/idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByDeclaration.after.kt @@ -0,0 +1,9 @@ +fun a() { + (fun(i: Int) { + + })( + + ) +} + +// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS \ No newline at end of file diff --git a/idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByDeclaration.kt b/idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByDeclaration.kt new file mode 100644 index 00000000000..20d774b8b08 --- /dev/null +++ b/idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByDeclaration.kt @@ -0,0 +1,7 @@ +fun a() { + (fun(i: Int) { + + })() +} + +// SET_FALSE: ALIGN_MULTILINE_METHOD_BRACKETS \ No newline at end of file diff --git a/idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByDeclaration2.after.kt b/idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByDeclaration2.after.kt new file mode 100644 index 00000000000..0580c02a391 --- /dev/null +++ b/idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByDeclaration2.after.kt @@ -0,0 +1,10 @@ +fun a() { + (fun(i: Int) { + + })( + + ) +} + +// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS +// IGNORE_FORMATTER \ No newline at end of file diff --git a/idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByDeclaration2.kt b/idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByDeclaration2.kt new file mode 100644 index 00000000000..a561574da36 --- /dev/null +++ b/idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByDeclaration2.kt @@ -0,0 +1,8 @@ +fun a() { + (fun(i: Int) { + + })() +} + +// SET_TRUE: ALIGN_MULTILINE_METHOD_BRACKETS +// IGNORE_FORMATTER \ No newline at end of file diff --git a/idea/testData/indentationOnNewline/emptyParenthesisInBinaryExpression/EmptyArgumentInCallByArrayAccess.after.inv.kt b/idea/testData/indentationOnNewline/emptyParenthesisInBinaryExpression/EmptyArgumentInCallByArrayAccess.after.inv.kt new file mode 100644 index 00000000000..534d7a84000 --- /dev/null +++ b/idea/testData/indentationOnNewline/emptyParenthesisInBinaryExpression/EmptyArgumentInCallByArrayAccess.after.inv.kt @@ -0,0 +1,8 @@ +fun a() { + val b = listOf(fun(c: Int) {}) + b[0]( + + ) +} + +// SET_FALSE: ALIGN_MULTILINE_BINARY_OPERATION diff --git a/idea/testData/indentationOnNewline/emptyParenthesisInBinaryExpression/EmptyArgumentInCallByArrayAccess.after.kt b/idea/testData/indentationOnNewline/emptyParenthesisInBinaryExpression/EmptyArgumentInCallByArrayAccess.after.kt new file mode 100644 index 00000000000..534d7a84000 --- /dev/null +++ b/idea/testData/indentationOnNewline/emptyParenthesisInBinaryExpression/EmptyArgumentInCallByArrayAccess.after.kt @@ -0,0 +1,8 @@ +fun a() { + val b = listOf(fun(c: Int) {}) + b[0]( + + ) +} + +// SET_FALSE: ALIGN_MULTILINE_BINARY_OPERATION diff --git a/idea/testData/indentationOnNewline/emptyParenthesisInBinaryExpression/EmptyArgumentInCallByArrayAccess.kt b/idea/testData/indentationOnNewline/emptyParenthesisInBinaryExpression/EmptyArgumentInCallByArrayAccess.kt new file mode 100644 index 00000000000..220941112ce --- /dev/null +++ b/idea/testData/indentationOnNewline/emptyParenthesisInBinaryExpression/EmptyArgumentInCallByArrayAccess.kt @@ -0,0 +1,6 @@ +fun a() { + val b = listOf(fun(c: Int) {}) + b[0]() +} + +// SET_FALSE: ALIGN_MULTILINE_BINARY_OPERATION diff --git a/idea/testData/indentationOnNewline/emptyParenthesisInBinaryExpression/EmptyArgumentInCallByDeclaration.after.inv.kt b/idea/testData/indentationOnNewline/emptyParenthesisInBinaryExpression/EmptyArgumentInCallByDeclaration.after.inv.kt new file mode 100644 index 00000000000..a6d886a5515 --- /dev/null +++ b/idea/testData/indentationOnNewline/emptyParenthesisInBinaryExpression/EmptyArgumentInCallByDeclaration.after.inv.kt @@ -0,0 +1,9 @@ +fun a() { + (fun(i: Int) { + + })( + + ) +} + +// SET_FALSE: ALIGN_MULTILINE_BINARY_OPERATION \ No newline at end of file diff --git a/idea/testData/indentationOnNewline/emptyParenthesisInBinaryExpression/EmptyArgumentInCallByDeclaration.after.kt b/idea/testData/indentationOnNewline/emptyParenthesisInBinaryExpression/EmptyArgumentInCallByDeclaration.after.kt new file mode 100644 index 00000000000..a6d886a5515 --- /dev/null +++ b/idea/testData/indentationOnNewline/emptyParenthesisInBinaryExpression/EmptyArgumentInCallByDeclaration.after.kt @@ -0,0 +1,9 @@ +fun a() { + (fun(i: Int) { + + })( + + ) +} + +// SET_FALSE: ALIGN_MULTILINE_BINARY_OPERATION \ No newline at end of file diff --git a/idea/testData/indentationOnNewline/emptyParenthesisInBinaryExpression/EmptyArgumentInCallByDeclaration.kt b/idea/testData/indentationOnNewline/emptyParenthesisInBinaryExpression/EmptyArgumentInCallByDeclaration.kt new file mode 100644 index 00000000000..811487a6e4d --- /dev/null +++ b/idea/testData/indentationOnNewline/emptyParenthesisInBinaryExpression/EmptyArgumentInCallByDeclaration.kt @@ -0,0 +1,7 @@ +fun a() { + (fun(i: Int) { + + })() +} + +// SET_FALSE: ALIGN_MULTILINE_BINARY_OPERATION \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/formatter/TypingIndentationTestBaseGenerated.java b/idea/tests/org/jetbrains/kotlin/formatter/TypingIndentationTestBaseGenerated.java index a70c6daa18b..d48f88365d1 100644 --- a/idea/tests/org/jetbrains/kotlin/formatter/TypingIndentationTestBaseGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/formatter/TypingIndentationTestBaseGenerated.java @@ -185,11 +185,36 @@ public class TypingIndentationTestBaseGenerated extends AbstractTypingIndentatio runTest("idea/testData/indentationOnNewline/KT20783.after.kt"); } + @TestMetadata("LambdaInArguments.after.kt") + public void testLambdaInArguments() throws Exception { + runTest("idea/testData/indentationOnNewline/LambdaInArguments.after.kt"); + } + + @TestMetadata("LambdaInArguments2.after.kt") + public void testLambdaInArguments2() throws Exception { + runTest("idea/testData/indentationOnNewline/LambdaInArguments2.after.kt"); + } + @TestMetadata("LargeFile.after.kt") public void testLargeFile() throws Exception { runTest("idea/testData/indentationOnNewline/LargeFile.after.kt"); } + @TestMetadata("LiteralExpression.after.kt") + public void testLiteralExpression() throws Exception { + runTest("idea/testData/indentationOnNewline/LiteralExpression.after.kt"); + } + + @TestMetadata("LiteralExpression2.after.kt") + public void testLiteralExpression2() throws Exception { + runTest("idea/testData/indentationOnNewline/LiteralExpression2.after.kt"); + } + + @TestMetadata("LiteralExpression3.after.kt") + public void testLiteralExpression3() throws Exception { + runTest("idea/testData/indentationOnNewline/LiteralExpression3.after.kt"); + } + @TestMetadata("ModifierListInUnfinishedDeclaration.after.kt") public void testModifierListInUnfinishedDeclaration() throws Exception { runTest("idea/testData/indentationOnNewline/ModifierListInUnfinishedDeclaration.after.kt"); @@ -546,6 +571,26 @@ public class TypingIndentationTestBaseGenerated extends AbstractTypingIndentatio KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/indentationOnNewline/emptyParameters"), Pattern.compile("^([^\\.]+)\\.after\\.kt.*$"), null, true); } + @TestMetadata("EmptyArgumentInCallByArrayAccess.after.kt") + public void testEmptyArgumentInCallByArrayAccess() throws Exception { + runTest("idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByArrayAccess.after.kt"); + } + + @TestMetadata("EmptyArgumentInCallByArrayAccess2.after.kt") + public void testEmptyArgumentInCallByArrayAccess2() throws Exception { + runTest("idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByArrayAccess2.after.kt"); + } + + @TestMetadata("EmptyArgumentInCallByDeclaration.after.kt") + public void testEmptyArgumentInCallByDeclaration() throws Exception { + runTest("idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByDeclaration.after.kt"); + } + + @TestMetadata("EmptyArgumentInCallByDeclaration2.after.kt") + public void testEmptyArgumentInCallByDeclaration2() throws Exception { + runTest("idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByDeclaration2.after.kt"); + } + @TestMetadata("EmptyArgumentInCallByReference.after.kt") public void testEmptyArgumentInCallByReference() throws Exception { runTest("idea/testData/indentationOnNewline/emptyParameters/EmptyArgumentInCallByReference.after.kt"); @@ -829,6 +874,16 @@ public class TypingIndentationTestBaseGenerated extends AbstractTypingIndentatio runTest("idea/testData/indentationOnNewline/emptyParenthesisInBinaryExpression/BinaryWithTypeExpressions.after.kt"); } + @TestMetadata("EmptyArgumentInCallByArrayAccess.after.kt") + public void testEmptyArgumentInCallByArrayAccess() throws Exception { + runTest("idea/testData/indentationOnNewline/emptyParenthesisInBinaryExpression/EmptyArgumentInCallByArrayAccess.after.kt"); + } + + @TestMetadata("EmptyArgumentInCallByDeclaration.after.kt") + public void testEmptyArgumentInCallByDeclaration() throws Exception { + runTest("idea/testData/indentationOnNewline/emptyParenthesisInBinaryExpression/EmptyArgumentInCallByDeclaration.after.kt"); + } + @TestMetadata("InBinaryExpressionInMiddle.after.kt") public void testInBinaryExpressionInMiddle() throws Exception { runTest("idea/testData/indentationOnNewline/emptyParenthesisInBinaryExpression/InBinaryExpressionInMiddle.after.kt"); @@ -1351,6 +1406,16 @@ public class TypingIndentationTestBaseGenerated extends AbstractTypingIndentatio runTest("idea/testData/indentationOnNewline/emptyParenthesisInBinaryExpression/BinaryWithTypeExpressions.after.inv.kt"); } + @TestMetadata("EmptyArgumentInCallByArrayAccess.after.inv.kt") + public void testEmptyArgumentInCallByArrayAccess() throws Exception { + runTest("idea/testData/indentationOnNewline/emptyParenthesisInBinaryExpression/EmptyArgumentInCallByArrayAccess.after.inv.kt"); + } + + @TestMetadata("EmptyArgumentInCallByDeclaration.after.inv.kt") + public void testEmptyArgumentInCallByDeclaration() throws Exception { + runTest("idea/testData/indentationOnNewline/emptyParenthesisInBinaryExpression/EmptyArgumentInCallByDeclaration.after.inv.kt"); + } + @TestMetadata("InBinaryExpressionInMiddle.after.inv.kt") public void testInBinaryExpressionInMiddle() throws Exception { runTest("idea/testData/indentationOnNewline/emptyParenthesisInBinaryExpression/InBinaryExpressionInMiddle.after.inv.kt");