From 9511348497e85782a67708171c19ae914268de25 Mon Sep 17 00:00:00 2001 From: Dmitry Gridin Date: Fri, 10 Jan 2020 12:59:36 +0700 Subject: [PATCH] TrailingCommaPostFormatProcessor: should be completed in one round #KT-34744 --- .../idea/formatter/KotlinCommonBlock.kt | 15 +- .../kotlin/idea/util/FormatterUtil.kt | 23 +-- .../TrailingCommaPostFormatProcessor.kt | 76 +++++----- idea/testData/formatter/When.after.inv.kt | 2 +- ...CollectionLiteralInAnnotation.after.inv.kt | 12 +- .../CollectionLiteralInAnnotation.after.kt | 18 +-- ...structionDeclarationsInLambda.after.inv.kt | 22 +-- .../DestructionDeclarationsInLambda.after.kt | 22 +-- .../DestructionDeclarationsInLambda.kt | 2 +- .../MultiVariableDeclaration.after.inv.kt | 29 ++-- .../MultiVariableDeclaration.after.kt | 30 ++-- .../MultiVariableDeclaration.kt | 11 ++ .../indices/IndicesAccess.after.inv.kt | 55 +++---- .../indices/IndicesAccess.after.kt | 92 +++--------- .../trailingComma/indices/IndicesAccess.kt | 9 +- .../LambdaParameterList.after.inv.kt | 4 +- .../LambdaParameterList.after.kt | 4 +- .../TypeArgumentList.after.inv.kt | 45 +++--- .../typeArguments/TypeArgumentList.after.kt | 82 +++-------- .../typeArguments/TypeArgumentList.kt | 9 ++ .../TypeParameterList.after.inv.kt | 4 +- .../typeParameters/TypeParameterList.after.kt | 4 +- .../ArgumentListChopAsNeeded.after.inv.kt | 110 +++++++------- .../ArgumentListChopAsNeeded.after.kt | 135 +++++++----------- .../ArgumentListChopAsNeeded.kt | 19 +++ .../ArgumentListDoNotWrap.after.inv.kt | 89 ++++++------ .../ArgumentListDoNotWrap.after.kt | 132 +++++++---------- .../valueArguments/ArgumentListDoNotWrap.kt | 19 +++ .../ArgumentListWrapAlways.after.inv.kt | 89 +++++++----- .../ArgumentListWrapAlways.after.kt | 107 +++++++------- .../valueArguments/ArgumentListWrapAlways.kt | 19 +++ .../ArgumentListWrapAsNeeded.after.inv.kt | 89 ++++++------ .../ArgumentListWrapAsNeeded.after.kt | 132 +++++++---------- .../ArgumentListWrapAsNeeded.kt | 19 +++ .../LambdaValueParameters.after.inv.kt | 12 +- .../LambdaValueParameters.after.kt | 12 +- .../valueParameters/LambdaValueParameters.kt | 5 + .../ParameterListChopAsNeeded.after.inv.kt | 12 +- .../ParameterListChopAsNeeded.after.kt | 12 +- .../ParameterListDoNotWrap.after.inv.kt | 12 +- .../ParameterListDoNotWrap.after.kt | 12 +- .../ParameterListWrapAlways.after.inv.kt | 8 +- .../ParameterListWrapAlways.after.kt | 8 +- .../ParameterListWrapAsNeeded.after.inv.kt | 12 +- .../ParameterListWrapAsNeeded.after.kt | 12 +- .../whenEntry/WhenEntry.after.inv.kt | 17 ++- .../whenEntry/WhenEntry.after.kt | 18 ++- .../trailingComma/whenEntry/WhenEntry.kt | 14 +- 48 files changed, 782 insertions(+), 913 deletions(-) diff --git a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt index 838a23988ba..e399a65173f 100644 --- a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt +++ b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt @@ -746,9 +746,7 @@ abstract class KotlinCommonBlock( } if (nodePsi.operationToken == ELVIS && nodePsi.getStrictParentOfType() == null) { return { childElement -> - if (childElement.elementType == OPERATION_REFERENCE && (childElement.psi as? KtOperationReferenceExpression) - ?.operationSignTokenType == ELVIS - ) { + if (childElement.elementType == OPERATION_REFERENCE && (childElement.psi as? KtOperationReferenceExpression)?.operationSignTokenType == ELVIS) { Wrap.createWrap(settings.kotlinCustomSettings.WRAP_ELVIS_EXPRESSIONS, true) } else { null @@ -766,11 +764,12 @@ abstract class KotlinCommonBlock( fun(childElement: ASTNode): Wrap? = trailingCommaWrappingStrategyWithMultiLineCheck(leftAnchor, rightAnchor)(childElement) private val ASTNode.withTrailingComma: Boolean - get() = when { - lastChildNode?.let { getSiblingWithoutWhitespaceAndComments(it) }?.elementType === COMMA -> true - settings.kotlinCustomSettings.ALLOW_TRAILING_COMMA -> psi?.let(PsiElement::isMultiline) == true - else -> false - } + get() = if (settings.kotlinCustomSettings.ALLOW_TRAILING_COMMA || + lastChildNode?.let { getSiblingWithoutWhitespaceAndComments(it) }?.elementType === COMMA + ) + psi?.let(PsiElement::isMultiline) == true + else + false private fun ASTNode.notDelimiterSiblingNodeInSequence( forward: Boolean, diff --git a/idea/formatter/src/org/jetbrains/kotlin/idea/util/FormatterUtil.kt b/idea/formatter/src/org/jetbrains/kotlin/idea/util/FormatterUtil.kt index 6d888cf34e6..33e376d31a4 100644 --- a/idea/formatter/src/org/jetbrains/kotlin/idea/util/FormatterUtil.kt +++ b/idea/formatter/src/org/jetbrains/kotlin/idea/util/FormatterUtil.kt @@ -47,26 +47,27 @@ fun PsiElement.getLineCount(): Int { fun PsiElement.isMultiline() = getLineCount() > 1 -fun KtFunctionLiteral.needTrailingComma(settings: CodeStyleSettings): Boolean = needTrailingComma( +fun KtFunctionLiteral.needTrailingComma(settings: CodeStyleSettings, checkTrailingComma: Boolean = true): Boolean = needTrailingComma( settings = settings, - trailingComma = { valueParameterList?.trailingComma }, + trailingComma = { if (checkTrailingComma) valueParameterList?.trailingComma else null }, globalStartOffset = { valueParameterList?.startOffset }, globalEndOffset = { arrow?.endOffset } ) -fun KtWhenEntry.needTrailingComma(settings: CodeStyleSettings): Boolean = needTrailingComma( +fun KtWhenEntry.needTrailingComma(settings: CodeStyleSettings, checkTrailingComma: Boolean = true): Boolean = needTrailingComma( settings = settings, - trailingComma = { trailingComma }, + trailingComma = { if (checkTrailingComma) trailingComma else null }, additionalCheck = { !isElse }, globalEndOffset = { arrow?.endOffset } ) -fun KtDestructuringDeclaration.needTrailingComma(settings: CodeStyleSettings): Boolean = needTrailingComma( - settings = settings, - trailingComma = { trailingComma }, - globalStartOffset = { lPar?.startOffset }, - globalEndOffset = { rPar?.endOffset } -) +fun KtDestructuringDeclaration.needTrailingComma(settings: CodeStyleSettings, checkTrailingComma: Boolean = true): Boolean = + needTrailingComma( + settings = settings, + trailingComma = { if (checkTrailingComma) trailingComma else null }, + globalStartOffset = { lPar?.startOffset }, + globalEndOffset = { rPar?.endOffset } + ) fun T.needTrailingComma( settings: CodeStyleSettings, @@ -74,7 +75,7 @@ fun T.needTrailingComma( additionalCheck: () -> Boolean = { true }, globalStartOffset: T.() -> Int? = PsiElement::startOffset, globalEndOffset: T.() -> Int? = PsiElement::endOffset -) = trailingComma() != null || settings.kotlinCustomSettings.ALLOW_TRAILING_COMMA && additionalCheck() && run(fun(): Boolean { +) = (trailingComma() != null || settings.kotlinCustomSettings.ALLOW_TRAILING_COMMA) && additionalCheck() && run(fun(): Boolean { val startOffset = globalStartOffset() ?: return false val endOffset = globalEndOffset() ?: return false return containsLineBreakInThis(startOffset, endOffset) diff --git a/idea/src/org/jetbrains/kotlin/idea/formatter/TrailingCommaPostFormatProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/formatter/TrailingCommaPostFormatProcessor.kt index e6225b00caf..28f2e7c7160 100644 --- a/idea/src/org/jetbrains/kotlin/idea/formatter/TrailingCommaPostFormatProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/formatter/TrailingCommaPostFormatProcessor.kt @@ -14,6 +14,7 @@ import com.intellij.psi.PsiFile import com.intellij.psi.PsiWhiteSpace import com.intellij.psi.codeStyle.CodeStyleManager import com.intellij.psi.codeStyle.CodeStyleSettings +import com.intellij.psi.impl.source.PostprocessReformattingAspect import com.intellij.psi.impl.source.codeStyle.PostFormatProcessor import com.intellij.psi.impl.source.codeStyle.PostFormatProcessorHelper import com.intellij.psi.tree.TokenSet @@ -27,6 +28,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getPrevSiblingIgnoringWhitespaceAndComme import org.jetbrains.kotlin.psi.psiUtil.siblings import org.jetbrains.kotlin.utils.addToStdlib.cast import org.jetbrains.kotlin.utils.addToStdlib.safeAs +import org.jetbrains.kotlin.utils.ifEmpty class TrailingCommaPostFormatProcessor : PostFormatProcessor { override fun processElement(source: PsiElement, settings: CodeStyleSettings): PsiElement = @@ -36,6 +38,8 @@ class TrailingCommaPostFormatProcessor : PostFormatProcessor { TrailingCommaVisitor(settings).processText(source, rangeToReformat) } +private fun postFormatIsEnable(source: PsiElement): Boolean = !PostprocessReformattingAspect.getInstance(source.project).isDisabled + private class TrailingCommaVisitor(val settings: CodeStyleSettings) : KtTreeVisitorVoid() { private val myPostProcessor = PostFormatProcessorHelper(settings.kotlinCommonSettings) @@ -86,52 +90,56 @@ private class TrailingCommaVisitor(val settings: CodeStyleSettings) : KtTreeVisi private fun processCommaOwner(parent: KtElement) { val lastElement = parent.lastCommaOwnerOrComma ?: return val elementType = lastElement.safeAs()?.elementType - if (elementType === KtTokens.COMMA || parent.needComma) { - // add a missing comma - if (elementType !== KtTokens.COMMA) { - changePsi(parent) { factory -> - lastElement.addCommaAfter(factory) - true + when { + parent.needComma(false) -> { + // add a missing comma + if (elementType !== KtTokens.COMMA) { + lastElement.addCommaAfter(KtPsiFactory(parent)) } - } - correctCommaPosition(parent) + correctCommaPosition(parent) + } + parent.needComma(true) -> { + if (elementType === KtTokens.COMMA) correctCommaPosition(parent) + } + elementType === KtTokens.COMMA -> { + // remove redundant comma + lastElement.delete() + } + } + + if (postFormatIsEnable(parent)) { + updatePsi(parent) } } - private val KtElement.needComma: Boolean - get() = when { - this is KtWhenEntry -> needTrailingComma(settings) - parent is KtFunctionLiteral -> parent.cast().needTrailingComma(settings) - this is KtDestructuringDeclaration -> needTrailingComma(settings) - else -> settings.kotlinCustomSettings.ALLOW_TRAILING_COMMA && isMultiline() - } + private fun KtElement.needComma(ignoreTrailingComma: Boolean): Boolean = when { + this is KtWhenEntry -> needTrailingComma(settings, ignoreTrailingComma) + parent is KtFunctionLiteral -> parent.cast().needTrailingComma(settings, ignoreTrailingComma) + this is KtDestructuringDeclaration -> needTrailingComma(settings, ignoreTrailingComma) + else -> (ignoreTrailingComma || settings.kotlinCustomSettings.ALLOW_TRAILING_COMMA) && isMultiline() + } - private fun changePsi(element: KtElement, update: (KtPsiFactory) -> Boolean) { + private fun updatePsi(element: KtElement) { val oldLength = element.textLength - if (update(KtPsiFactory(element))) { + PostprocessReformattingAspect.getInstance(element.project).disablePostprocessFormattingInside { val result = CodeStyleManager.getInstance(element.project).reformat(element) myPostProcessor.updateResultRange(oldLength, result.textLength) } } private fun correctCommaPosition(parent: KtElement) { + if (!postFormatIsEnable(parent)) return + val invalidElements = parent.firstChild?.siblings(withItself = false)?.mapNotNull { if (it.safeAs()?.elementType != KtTokens.COMMA) return@mapNotNull null it.createSmartPointer() - }?.toList() ?: return + }?.toList().orEmpty().ifEmpty { return } - if (invalidElements.isNotEmpty()) { - changePsi(parent) { factory -> - var change = false - for (pointerToComma in invalidElements) { - pointerToComma.element?.let { - if (correctComma(it, factory)) { - change = true - } - } - } - change + val factory = KtPsiFactory(parent) + for (pointerToComma in invalidElements) { + pointerToComma.element?.let { + correctComma(it, factory) } } } @@ -161,25 +169,21 @@ private fun PsiElement.addCommaAfter(factory: KtPsiFactory) { parent.addAfter(comma, this) } -private fun correctComma(comma: PsiElement, factory: KtPsiFactory): Boolean { +private fun correctComma(comma: PsiElement, factory: KtPsiFactory) { val prevWithComment = comma.getPrevSiblingIgnoringWhitespace(false) val prevWithoutComment = comma.getPrevSiblingIgnoringWhitespaceAndComments(false) - return when { + when { prevWithoutComment?.equals(prevWithComment) == false -> { prevWithoutComment.addCommaAfter(factory) comma.delete() - true } prevWithoutComment is KtParameter -> { val check = { element: PsiElement -> element is PsiWhiteSpace || element is PsiComment } - val lastElement = prevWithoutComment.lastChild?.takeIf(check) ?: return false + val lastElement = prevWithoutComment.lastChild?.takeIf(check) ?: return val firstElement = lastElement.siblings(forward = false, withItself = true).takeWhile(check).last() comma.parent.addRangeAfter(firstElement, lastElement, comma) prevWithoutComment.deleteChildRange(firstElement, lastElement) - true } - else -> - false } } diff --git a/idea/testData/formatter/When.after.inv.kt b/idea/testData/formatter/When.after.inv.kt index 09b6b5fdc5e..91a96e03a53 100644 --- a/idea/testData/formatter/When.after.inv.kt +++ b/idea/testData/formatter/When.after.inv.kt @@ -1,7 +1,7 @@ fun some(x: Any) { when (x) { is Number -> 0 - else -> 1 + else -> 1 } when { } diff --git a/idea/testData/formatter/trailingComma/collectionLiteralExpression/CollectionLiteralInAnnotation.after.inv.kt b/idea/testData/formatter/trailingComma/collectionLiteralExpression/CollectionLiteralInAnnotation.after.inv.kt index e94bc3b5915..3eeca972c74 100644 --- a/idea/testData/formatter/trailingComma/collectionLiteralExpression/CollectionLiteralInAnnotation.after.inv.kt +++ b/idea/testData/formatter/trailingComma/collectionLiteralExpression/CollectionLiteralInAnnotation.after.inv.kt @@ -3,9 +3,7 @@ @Anno([1]) fun a() = Unit -@Anno([ - 1, -]) +@Anno([1]) fun a() = Unit @Anno([1 @@ -24,9 +22,7 @@ fun a() = Unit @Anno([1, 2]) fun a() = Unit -@Anno([ - 1, 2, -]) +@Anno([1, 2]) fun a() = Unit @Anno([1, 2 @@ -45,9 +41,7 @@ fun a() = Unit @Anno([1, 2, 2]) fun a() = Unit -@Anno([ - 1, 2, 2, -]) +@Anno([1, 2, 2]) fun a() = Unit @Anno(["1" diff --git a/idea/testData/formatter/trailingComma/collectionLiteralExpression/CollectionLiteralInAnnotation.after.kt b/idea/testData/formatter/trailingComma/collectionLiteralExpression/CollectionLiteralInAnnotation.after.kt index 467ad2d0512..bd5a487efb4 100644 --- a/idea/testData/formatter/trailingComma/collectionLiteralExpression/CollectionLiteralInAnnotation.after.kt +++ b/idea/testData/formatter/trailingComma/collectionLiteralExpression/CollectionLiteralInAnnotation.after.kt @@ -3,11 +3,7 @@ @Anno([1]) fun a() = Unit -@Anno( - [ - 1, - ], -) +@Anno([1]) fun a() = Unit @Anno( @@ -34,11 +30,7 @@ fun a() = Unit @Anno([1, 2]) fun a() = Unit -@Anno( - [ - 1, 2, - ], -) +@Anno([1, 2]) fun a() = Unit @Anno( @@ -65,11 +57,7 @@ fun a() = Unit @Anno([1, 2, 2]) fun a() = Unit -@Anno( - [ - 1, 2, 2, - ], -) +@Anno([1, 2, 2]) fun a() = Unit @Anno( diff --git a/idea/testData/formatter/trailingComma/destructionDeclaration/DestructionDeclarationsInLambda.after.inv.kt b/idea/testData/formatter/trailingComma/destructionDeclaration/DestructionDeclarationsInLambda.after.inv.kt index f2d2a81d571..2ac0625600d 100644 --- a/idea/testData/formatter/trailingComma/destructionDeclaration/DestructionDeclarationsInLambda.after.inv.kt +++ b/idea/testData/formatter/trailingComma/destructionDeclaration/DestructionDeclarationsInLambda.after.inv.kt @@ -1,16 +1,10 @@ // SET_TRUE: ALLOW_TRAILING_COMMA -val x: (Pair, Int) -> Unit = { - ( - x, y, - ), /* FIXME: The result should converge in one iteration */ z, - -> +val x: (Pair, Int) -> Unit = { (x, y), z -> println(x) } -val x: (Pair, Int) -> Unit = { - (x, y), z, - -> +val x: (Pair, Int) -> Unit = { (x, y), z -> println(x) } @@ -52,15 +46,11 @@ val x: (Pair, Int) -> Unit = { println(x) } -val x: (Pair, Int) -> Unit = { - (x, y), z, - -> +val x: (Pair, Int) -> Unit = { (x, y), z -> println(x) } -val x: (Pair, Int) -> Unit = { - (x, y/**/), z, - -> +val x: (Pair, Int) -> Unit = { (x, y/**/), z -> println(x) } @@ -93,9 +83,7 @@ val x: (Pair, Int) -> Unit = { } val x: (Pair, Int) -> Unit = { - ( - x, y, - ), + (x, y), z, -> println(x) diff --git a/idea/testData/formatter/trailingComma/destructionDeclaration/DestructionDeclarationsInLambda.after.kt b/idea/testData/formatter/trailingComma/destructionDeclaration/DestructionDeclarationsInLambda.after.kt index 71318b3b3bd..2c0cb7b1a41 100644 --- a/idea/testData/formatter/trailingComma/destructionDeclaration/DestructionDeclarationsInLambda.after.kt +++ b/idea/testData/formatter/trailingComma/destructionDeclaration/DestructionDeclarationsInLambda.after.kt @@ -1,16 +1,10 @@ // SET_TRUE: ALLOW_TRAILING_COMMA -val x: (Pair, Int) -> Unit = { - ( - x, y, - ), /* FIXME: The result should converge in one iteration */ z, - -> +val x: (Pair, Int) -> Unit = { (x, y), z -> println(x) } -val x: (Pair, Int) -> Unit = { - (x, y), z, - -> +val x: (Pair, Int) -> Unit = { (x, y), z -> println(x) } @@ -55,15 +49,11 @@ val x: (Pair, Int) -> Unit = { println(x) } -val x: (Pair, Int) -> Unit = { - (x, y), z, - -> +val x: (Pair, Int) -> Unit = { (x, y), z -> println(x) } -val x: (Pair, Int) -> Unit = { - (x, y/**/), z, - -> +val x: (Pair, Int) -> Unit = { (x, y/**/), z -> println(x) } @@ -105,9 +95,7 @@ val x: (Pair, Int) -> Unit = { } val x: (Pair, Int) -> Unit = { - ( - x, y, - ), + (x, y), z, -> println(x) diff --git a/idea/testData/formatter/trailingComma/destructionDeclaration/DestructionDeclarationsInLambda.kt b/idea/testData/formatter/trailingComma/destructionDeclaration/DestructionDeclarationsInLambda.kt index f80aa3aace8..159a0df2cba 100644 --- a/idea/testData/formatter/trailingComma/destructionDeclaration/DestructionDeclarationsInLambda.kt +++ b/idea/testData/formatter/trailingComma/destructionDeclaration/DestructionDeclarationsInLambda.kt @@ -1,6 +1,6 @@ // SET_TRUE: ALLOW_TRAILING_COMMA -val x: (Pair, Int) -> Unit = { (x, y,), /* FIXME: The result should converge in one iteration */ z, -> +val x: (Pair, Int) -> Unit = { (x, y,), z, -> println(x) } diff --git a/idea/testData/formatter/trailingComma/destructionDeclaration/MultiVariableDeclaration.after.inv.kt b/idea/testData/formatter/trailingComma/destructionDeclaration/MultiVariableDeclaration.after.inv.kt index 47d172ba926..27c551b6bf7 100644 --- a/idea/testData/formatter/trailingComma/destructionDeclaration/MultiVariableDeclaration.after.inv.kt +++ b/idea/testData/formatter/trailingComma/destructionDeclaration/MultiVariableDeclaration.after.inv.kt @@ -11,15 +11,22 @@ fun test() { 2 - val ( - a, b, - ) = 1 to 2 + val (a, b) = 1 to 2 + + val (a) = + b val ( a, ) = b + val (a + ) = + b + + val (a) = b + val ( a, ) = b @@ -56,22 +63,14 @@ fun test() { to 2 - val ( - a, b,/**/ - ) = 1 to 2 + val (a, b/**/) = 1 to 2 - val ( - a,/**/ b,/**//**/ - ) = 1 to 2 + val (a/**/, b/**//**/) = 1 to 2 - val ( - a,/**//**/ - ) = + val (a/**//**/) = b - val ( - a, - ) = b + val (a) = b val (a, b/**/ ) = 1 to 2 diff --git a/idea/testData/formatter/trailingComma/destructionDeclaration/MultiVariableDeclaration.after.kt b/idea/testData/formatter/trailingComma/destructionDeclaration/MultiVariableDeclaration.after.kt index cfabfc847da..77079929bf7 100644 --- a/idea/testData/formatter/trailingComma/destructionDeclaration/MultiVariableDeclaration.after.kt +++ b/idea/testData/formatter/trailingComma/destructionDeclaration/MultiVariableDeclaration.after.kt @@ -11,15 +11,23 @@ fun test() { 2 - val ( - a, b, - ) = 1 to 2 + val (a, b) = 1 to 2 + + val (a) = + b val ( a, ) = b + val ( + a, + ) = + b + + val (a) = b + val ( a, ) = b @@ -60,22 +68,14 @@ fun test() { to 2 - val ( - a, b,/**/ - ) = 1 to 2 + val (a, b/**/) = 1 to 2 - val ( - a,/**/ b,/**//**/ - ) = 1 to 2 + val (a/**/, b/**//**/) = 1 to 2 - val ( - a,/**//**/ - ) = + val (a/**//**/) = b - val ( - a, - ) = b + val (a) = b val ( a, b,/**/ diff --git a/idea/testData/formatter/trailingComma/destructionDeclaration/MultiVariableDeclaration.kt b/idea/testData/formatter/trailingComma/destructionDeclaration/MultiVariableDeclaration.kt index 54fad967e6b..03de853879e 100644 --- a/idea/testData/formatter/trailingComma/destructionDeclaration/MultiVariableDeclaration.kt +++ b/idea/testData/formatter/trailingComma/destructionDeclaration/MultiVariableDeclaration.kt @@ -16,8 +16,19 @@ fun test() { val (a,) = b + val (a, + ) = + b + + val (a + ) = + b + val (a,) = b + val ( + a,) = b + val (a, b ) = 1 to 2 diff --git a/idea/testData/formatter/trailingComma/indices/IndicesAccess.after.inv.kt b/idea/testData/formatter/trailingComma/indices/IndicesAccess.after.inv.kt index c8818aad243..ee6fad75cbf 100644 --- a/idea/testData/formatter/trailingComma/indices/IndicesAccess.after.inv.kt +++ b/idea/testData/formatter/trailingComma/indices/IndicesAccess.after.inv.kt @@ -25,23 +25,18 @@ fun foo() { foofoo ] - testtest[ - foofoo, - ] + testtest[foofoo] testtest[foofoo, testtest[testtest[foofoo]]] testtest[ - foofoo, fososos, testtest[testtest[foofoo]], + foofoo, fososos, + testtest[testtest[foofoo]], ] - testtest[foofoo, testtest[testtest[ - foofoo, - ]], testsa] + testtest[foofoo, testtest[testtest[foofoo]], testsa] - testtest[foofoo, seee, testtest[testtest[ - foofoo, - ]], testsa] + testtest[foofoo, seee, testtest[testtest[foofoo]], testsa] useCallable["A", Callable { println["Hello world"] }] @@ -53,8 +48,12 @@ fun foo() { useCallable[Callable { println["Hello world"] }] + useCallable[Callable { println["Hello world"] }] + useCallable[ - Callable { println["Hello world"] }, + Callable { + println["Hello world"] + }, ] useCallable[Callable { println["Hello world"] } @@ -77,6 +76,8 @@ fun foo() { useCallable[{ println["Hello world"] }] + useCallable[{ println["Hello world"] }] + useCallable[ { println["Hello world"] }, ] @@ -103,9 +104,7 @@ fun foo() { override fun call() { println["Hello world"] } - }, foo[ - 0, - ]] + }, foo[0]] useCallable[object : Callable { override fun call() { @@ -174,9 +173,7 @@ fun foo() { foofoo ] - testtest[ - foofoo,/**/ - ] + testtest[foofoo/**/] testtest[foofoo, foofoo, foofoo, foofoo/* */, /* */ bar @@ -189,9 +186,7 @@ fun foo() { foofoo ] - testtest[ - foofoo,/**/ - ] + testtest[foofoo/**/] testtest[ foofoo, fososos,/* @@ -199,26 +194,16 @@ fun foo() { testtest[testtest[foofoo]], ] - testtest[foofoo, testtest[testtest[ - foofoo, - ]], /**/testsa] + testtest[foofoo, testtest[testtest[foofoo]], /**/testsa] - testtest[foofoo, testtest[testtest[ - foofoo, - ]]/* */, /**/testsa] + testtest[foofoo, testtest[testtest[foofoo]]/* */, /**/testsa] - testtest[foofoo, testtest[testtest[ - foofoo, - ]]/* + testtest[foofoo, testtest[testtest[foofoo]]/* */, testsa] - testtest[foofoo, seee, testtest[testtest[ - foofoo, - ]], /**/testsa] + testtest[foofoo, seee, testtest[testtest[foofoo]], /**/testsa] - testtest[foofoo, seee, testtest[testtest[ - foofoo, - ]], /* + testtest[foofoo, seee, testtest[testtest[foofoo]], /* */testsa] useCallable["B", "C", Callable { diff --git a/idea/testData/formatter/trailingComma/indices/IndicesAccess.after.kt b/idea/testData/formatter/trailingComma/indices/IndicesAccess.after.kt index 7dc62fc9db3..2844cebc48c 100644 --- a/idea/testData/formatter/trailingComma/indices/IndicesAccess.after.kt +++ b/idea/testData/formatter/trailingComma/indices/IndicesAccess.after.kt @@ -31,35 +31,18 @@ fun foo() { foofoo, ] - testtest[ - foofoo, - ] + testtest[foofoo] testtest[foofoo, testtest[testtest[foofoo]]] testtest[ - foofoo, fososos, testtest[testtest[foofoo]], + foofoo, fososos, + testtest[testtest[foofoo]], ] - testtest[ - foofoo, - testtest[ - testtest[ - foofoo, - ], - ], - testsa, - ] + testtest[foofoo, testtest[testtest[foofoo]], testsa] - testtest[ - foofoo, seee, - testtest[ - testtest[ - foofoo, - ], - ], - testsa, - ] + testtest[foofoo, seee, testtest[testtest[foofoo]], testsa] useCallable["A", Callable { println["Hello world"] }] @@ -75,8 +58,12 @@ fun foo() { useCallable[Callable { println["Hello world"] }] + useCallable[Callable { println["Hello world"] }] + useCallable[ - Callable { println["Hello world"] }, + Callable { + println["Hello world"] + }, ] useCallable[ @@ -105,6 +92,8 @@ fun foo() { useCallable[{ println["Hello world"] }] + useCallable[{ println["Hello world"] }] + useCallable[ { println["Hello world"] }, ] @@ -142,9 +131,7 @@ fun foo() { println["Hello world"] } }, - foo[ - 0, - ], + foo[0], ] useCallable[ @@ -231,9 +218,7 @@ fun foo() { foofoo, ] - testtest[ - foofoo,/**/ - ] + testtest[foofoo/**/] testtest[ foofoo, foofoo, foofoo, @@ -251,9 +236,7 @@ fun foo() { foofoo, ] - testtest[ - foofoo,/**/ - ] + testtest[foofoo/**/] testtest[ foofoo, fososos,/* @@ -261,54 +244,21 @@ fun foo() { testtest[testtest[foofoo]], ] - testtest[ - foofoo, - testtest[ - testtest[ - foofoo, - ], - ], /**/ - testsa, - ] + testtest[foofoo, testtest[testtest[foofoo]], /**/testsa] + + testtest[foofoo, testtest[testtest[foofoo]]/* */, /**/testsa] testtest[ foofoo, - testtest[ - testtest[ - foofoo, - ], - ],/* */ /**/ - testsa, - ] - - testtest[ - foofoo, - testtest[ - testtest[ - foofoo, - ], - ],/* + testtest[testtest[foofoo]],/* */ testsa, ] - testtest[ - foofoo, seee, - testtest[ - testtest[ - foofoo, - ], - ], /**/ - testsa, - ] + testtest[foofoo, seee, testtest[testtest[foofoo]], /**/testsa] testtest[ - foofoo, seee, - testtest[ - testtest[ - foofoo, - ], - ], /* + foofoo, seee, testtest[testtest[foofoo]], /* */ testsa, ] diff --git a/idea/testData/formatter/trailingComma/indices/IndicesAccess.kt b/idea/testData/formatter/trailingComma/indices/IndicesAccess.kt index 5a2410b99c5..83bd34e7caf 100644 --- a/idea/testData/formatter/trailingComma/indices/IndicesAccess.kt +++ b/idea/testData/formatter/trailingComma/indices/IndicesAccess.kt @@ -29,7 +29,8 @@ fun foo() { testtest[foofoo, testtest[testtest[foofoo]]] - testtest[foofoo, fososos, testtest[testtest[foofoo]],] + testtest[foofoo, fososos, + testtest[testtest[foofoo]],] testtest[foofoo, testtest[testtest[foofoo,]], testsa] @@ -47,6 +48,9 @@ fun foo() { useCallable[Callable { println["Hello world"] },] + useCallable[Callable { + println["Hello world"] },] + useCallable[Callable { println["Hello world"] } ] @@ -69,6 +73,9 @@ fun foo() { useCallable[{ println["Hello world"] },] + useCallable[{ println["Hello world"] } + ,] + useCallable[{ println["Hello world"] } ] diff --git a/idea/testData/formatter/trailingComma/lambdaParameters/LambdaParameterList.after.inv.kt b/idea/testData/formatter/trailingComma/lambdaParameters/LambdaParameterList.after.inv.kt index 990b3979b38..55175344225 100644 --- a/idea/testData/formatter/trailingComma/lambdaParameters/LambdaParameterList.after.inv.kt +++ b/idea/testData/formatter/trailingComma/lambdaParameters/LambdaParameterList.after.inv.kt @@ -76,9 +76,7 @@ val x = { x: String println("1") } -val x = { - x: String, - -> +val x = { x: String -> println("1") } diff --git a/idea/testData/formatter/trailingComma/lambdaParameters/LambdaParameterList.after.kt b/idea/testData/formatter/trailingComma/lambdaParameters/LambdaParameterList.after.kt index 35c8b8af142..cfc30823c94 100644 --- a/idea/testData/formatter/trailingComma/lambdaParameters/LambdaParameterList.after.kt +++ b/idea/testData/formatter/trailingComma/lambdaParameters/LambdaParameterList.after.kt @@ -82,9 +82,7 @@ val x = { println("1") } -val x = { - x: String, - -> +val x = { x: String -> println("1") } diff --git a/idea/testData/formatter/trailingComma/typeArguments/TypeArgumentList.after.inv.kt b/idea/testData/formatter/trailingComma/typeArguments/TypeArgumentList.after.inv.kt index 89e803e114e..4345cac8a65 100644 --- a/idea/testData/formatter/trailingComma/typeArguments/TypeArgumentList.after.inv.kt +++ b/idea/testData/formatter/trailingComma/typeArguments/TypeArgumentList.after.inv.kt @@ -35,23 +35,19 @@ fun foo() { foofoo >() - testtest< - foofoo, - >() + testtest() testtest>>() + testtest>>() + testtest< foofoo, fososos, testtest>, >() - testtest>, testsa>() + testtest>, testsa>() - testtest>, testsa>() + testtest>, testsa>() testtest< foofoo, foofoo, foofoo, foofoo, @@ -84,9 +80,7 @@ fun foo() { foofoo >() - testtest< - foofoo,/**/ - >() + testtest() testtest() + testtest() + + testtest< + foofoo,/* + */ + >() + testtest< foofoo,/**/ >() @@ -109,25 +110,15 @@ fun foo() { testtest>, >() - testtest>, /**/testsa>() + testtest>, /**/testsa>() - testtest>/* */, /**/testsa>() + testtest>/* */, /**/testsa>() - testtest>/* + testtest>/* */, testsa>() - testtest>, /**/testsa>() + testtest>, /**/testsa>() - testtest>, /* + testtest>, /* */testsa>() } \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/typeArguments/TypeArgumentList.after.kt b/idea/testData/formatter/trailingComma/typeArguments/TypeArgumentList.after.kt index 2224c4ea0c2..8f5452676a7 100644 --- a/idea/testData/formatter/trailingComma/typeArguments/TypeArgumentList.after.kt +++ b/idea/testData/formatter/trailingComma/typeArguments/TypeArgumentList.after.kt @@ -41,35 +41,19 @@ fun foo() { foofoo, >() - testtest< - foofoo, - >() + testtest() testtest>>() + testtest>>() + testtest< foofoo, fososos, testtest>, >() - testtest< - foofoo, - testtest< - testtest< - foofoo, - >, - >, - testsa, - >() + testtest>, testsa>() - testtest< - foofoo, *, - testtest< - testtest< - foofoo, - >, - >, - testsa, - >() + testtest>, testsa>() testtest< foofoo, foofoo, foofoo, foofoo, @@ -113,9 +97,7 @@ fun foo() { foofoo, >() - testtest< - foofoo,/**/ - >() + testtest() testtest< foofoo, foofoo, foofoo, @@ -133,6 +115,13 @@ fun foo() { foofoo, >() + testtest() + + testtest< + foofoo,/* + */ + >() + testtest< foofoo,/**/ >() @@ -143,54 +132,21 @@ fun foo() { testtest>, >() - testtest< - foofoo, - testtest< - testtest< - foofoo, - >, - >, /**/ - testsa, - >() + testtest>, /**/testsa>() + + testtest>/* */, /**/testsa>() testtest< foofoo, - testtest< - testtest< - foofoo, - >, - >,/* */ /**/ - testsa, - >() - - testtest< - foofoo, - testtest< - testtest< - foofoo, - >, - >,/* + testtest>,/* */ testsa, >() - testtest< - foofoo, seee, - testtest< - testtest< - foofoo, - >, - >, /**/ - testsa, - >() + testtest>, /**/testsa>() testtest< - foofoo, seee, - testtest< - testtest< - foofoo, - >, - >, /* + foofoo, seee, testtest>, /* */ testsa, >() diff --git a/idea/testData/formatter/trailingComma/typeArguments/TypeArgumentList.kt b/idea/testData/formatter/trailingComma/typeArguments/TypeArgumentList.kt index d1c32bea453..363631ca312 100644 --- a/idea/testData/formatter/trailingComma/typeArguments/TypeArgumentList.kt +++ b/idea/testData/formatter/trailingComma/typeArguments/TypeArgumentList.kt @@ -39,6 +39,9 @@ fun foo() { testtest>,>() + testtest> + ,>() + testtest>, testsa>() testtest>, testsa>() @@ -89,6 +92,12 @@ fun foo() { testtest() + testtest() + + testtest< + foofoo,/**/>() + testtest>,>() diff --git a/idea/testData/formatter/trailingComma/typeParameters/TypeParameterList.after.inv.kt b/idea/testData/formatter/trailingComma/typeParameters/TypeParameterList.after.inv.kt index 20c71c2cab4..4a79a540ec2 100644 --- a/idea/testData/formatter/trailingComma/typeParameters/TypeParameterList.after.inv.kt +++ b/idea/testData/formatter/trailingComma/typeParameters/TypeParameterList.after.inv.kt @@ -193,9 +193,7 @@ fun ag() { } -fun < - T, - > ag() { +fun ag() { } diff --git a/idea/testData/formatter/trailingComma/typeParameters/TypeParameterList.after.kt b/idea/testData/formatter/trailingComma/typeParameters/TypeParameterList.after.kt index e6a3a89114c..e6fb9c6bab7 100644 --- a/idea/testData/formatter/trailingComma/typeParameters/TypeParameterList.after.kt +++ b/idea/testData/formatter/trailingComma/typeParameters/TypeParameterList.after.kt @@ -197,9 +197,7 @@ fun ag() { } -fun < - T, - > ag() { +fun ag() { } diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.after.inv.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.after.inv.kt index 2c15f0a2854..f05aabdc1df 100644 --- a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.after.inv.kt +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.after.inv.kt @@ -26,28 +26,15 @@ fun foo() { foofoo ) - testtest( - foofoo, - ) + testtest(foofoo) testtest(foofoo, testtest(testtest(foofoo))) - testtest( - foofoo, fososos, testtest(testtest(foofoo)), - ) + testtest(foofoo, fososos, testtest(testtest(foofoo))) - testtest(foofoo, - testtest(testtest( - foofoo, - )), - testsa) + testtest(foofoo, testtest(testtest(foofoo)), testsa) - testtest(foofoo, - seee, - testtest(testtest( - foofoo, - )), - testsa) + testtest(foofoo, seee, testtest(testtest(foofoo)), testsa) useCallable("A", Callable { println("Hello world") }) @@ -59,9 +46,7 @@ fun foo() { useCallable(Callable { println("Hello world") }) - useCallable( - Callable { println("Hello world") }, - ) + useCallable(Callable { println("Hello world") }) useCallable(Callable { println("Hello world") } ) @@ -83,9 +68,7 @@ fun foo() { useCallable({ println("Hello world") }) - useCallable( - { println("Hello world") }, - ) + useCallable({ println("Hello world") }) useCallable({ println("Hello world") } ) @@ -107,9 +90,7 @@ fun foo() { useCallable(foo() { println("Hello world") }) - useCallable( - foo() { println("Hello world") }, - ) + useCallable(foo() { println("Hello world") }) useCallable(foo() { println("Hello world") } ) @@ -208,9 +189,7 @@ fun foo() { foofoo ) - testtest( - foofoo,/**/ - ) + testtest(foofoo/**/) testtest(foofoo, foofoo, foofoo, foofoo/* */, /* */ bar @@ -223,9 +202,7 @@ fun foo() { foofoo ) - testtest( - foofoo,/**/ - ) + testtest(foofoo/**/) testtest( foofoo, fososos,/* @@ -233,39 +210,17 @@ fun foo() { testtest(testtest(foofoo)), ) - testtest(foofoo, - testtest(testtest( - foofoo, - )), /**/ - testsa) + testtest(foofoo, testtest(testtest(foofoo)), /**/testsa) - testtest(foofoo, - testtest(testtest( - foofoo, - ))/* */, /**/ - testsa) + testtest(foofoo, testtest(testtest(foofoo))/* */, /**/testsa) - testtest(foofoo, - testtest(testtest( - foofoo, - ))/* - */, - testsa) + testtest(foofoo, testtest(testtest(foofoo))/* + */, testsa) - testtest(foofoo, - seee, - testtest(testtest( - foofoo, - )), /**/ - testsa) + testtest(foofoo, seee, testtest(testtest(foofoo)), /**/testsa) - testtest(foofoo, - seee, - testtest(testtest( - foofoo, - )), /* - */ - testsa) + testtest(foofoo, seee, testtest(testtest(foofoo)), /* + */testsa) useCallable("B", "C", Callable { println("Hello world") @@ -275,4 +230,37 @@ fun foo() { useCallable(Callable { println("Hello world") } // ffd ) + + useCallable( + object : Callable { + override fun call() { + println("Hello world") + } + }, + ) + + useCallable( + foo() { + println("Hello world") + }, + ) + + useCallable( + { + println("Hello world") + }, + ) + + useCallable( + Callable { println("Hello world") }, + ) + + testtest(foofoo, testtest(testtest( + foofoo, + )), testsa) + + testtest( + foofoo, fososos, testtest(testtest(foofoo)), + ) + } \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.after.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.after.kt index ba02979d506..0851a0344f2 100644 --- a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.after.kt +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.after.kt @@ -32,36 +32,15 @@ fun foo() { foofoo, ) - testtest( - foofoo, - ) + testtest(foofoo) testtest(foofoo, testtest(testtest(foofoo))) - testtest( - foofoo, fososos, testtest(testtest(foofoo)), - ) + testtest(foofoo, fososos, testtest(testtest(foofoo))) - testtest( - foofoo, - testtest( - testtest( - foofoo, - ), - ), - testsa, - ) + testtest(foofoo, testtest(testtest(foofoo)), testsa) - testtest( - foofoo, - seee, - testtest( - testtest( - foofoo, - ), - ), - testsa, - ) + testtest(foofoo, seee, testtest(testtest(foofoo)), testsa) useCallable("A", Callable { println("Hello world") }) @@ -77,9 +56,7 @@ fun foo() { useCallable(Callable { println("Hello world") }) - useCallable( - Callable { println("Hello world") }, - ) + useCallable(Callable { println("Hello world") }) useCallable( Callable { println("Hello world") }, @@ -107,9 +84,7 @@ fun foo() { useCallable({ println("Hello world") }) - useCallable( - { println("Hello world") }, - ) + useCallable({ println("Hello world") }) useCallable( { println("Hello world") }, @@ -137,9 +112,7 @@ fun foo() { useCallable(foo() { println("Hello world") }) - useCallable( - foo() { println("Hello world") }, - ) + useCallable(foo() { println("Hello world") }) useCallable( foo() { println("Hello world") }, @@ -267,9 +240,7 @@ fun foo() { foofoo, ) - testtest( - foofoo,/**/ - ) + testtest(foofoo/**/) testtest( foofoo, foofoo, foofoo, @@ -287,9 +258,7 @@ fun foo() { foofoo, ) - testtest( - foofoo,/**/ - ) + testtest(foofoo/**/) testtest( foofoo, fososos,/* @@ -297,56 +266,21 @@ fun foo() { testtest(testtest(foofoo)), ) - testtest( - foofoo, - testtest( - testtest( - foofoo, - ), - ), /**/ - testsa, - ) + testtest(foofoo, testtest(testtest(foofoo)), /**/testsa) + + testtest(foofoo, testtest(testtest(foofoo))/* */, /**/testsa) testtest( foofoo, - testtest( - testtest( - foofoo, - ), - ),/* */ /**/ - testsa, - ) - - testtest( - foofoo, - testtest( - testtest( - foofoo, - ), - ),/* + testtest(testtest(foofoo)),/* */ testsa, ) - testtest( - foofoo, - seee, - testtest( - testtest( - foofoo, - ), - ), /**/ - testsa, - ) + testtest(foofoo, seee, testtest(testtest(foofoo)), /**/testsa) testtest( - foofoo, - seee, - testtest( - testtest( - foofoo, - ), - ), /* + foofoo, seee, testtest(testtest(foofoo)), /* */ testsa, ) @@ -364,4 +298,43 @@ fun foo() { useCallable( Callable { println("Hello world") }, // ffd ) + + useCallable( + object : Callable { + override fun call() { + println("Hello world") + } + }, + ) + + useCallable( + foo() { + println("Hello world") + }, + ) + + useCallable( + { + println("Hello world") + }, + ) + + useCallable( + Callable { println("Hello world") }, + ) + + testtest( + foofoo, + testtest( + testtest( + foofoo, + ), + ), + testsa, + ) + + testtest( + foofoo, fososos, testtest(testtest(foofoo)), + ) + } \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.kt index 817aab799c3..153140b5b7b 100644 --- a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.kt +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.kt @@ -197,4 +197,23 @@ fun foo() { useCallable(Callable { println("Hello world") } // ffd ) + + useCallable(object : Callable { override fun call() { println("Hello world") } + },) + + useCallable(foo() { println("Hello world") + },) + + useCallable({ + println("Hello world") },) + + useCallable(Callable { println("Hello world") } + ,) + + testtest(foofoo, testtest(testtest( + foofoo,)), testsa) + + testtest(foofoo, fososos, testtest(testtest(foofoo)) + ,) + } \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.after.inv.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.after.inv.kt index 6bb5b656bba..0282bef8af0 100644 --- a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.after.inv.kt +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.after.inv.kt @@ -26,23 +26,15 @@ fun foo() { foofoo ) - testtest( - foofoo, - ) + testtest(foofoo) testtest(foofoo, testtest(testtest(foofoo))) - testtest( - foofoo, fososos, testtest(testtest(foofoo)), - ) + testtest(foofoo, fososos, testtest(testtest(foofoo))) - testtest(foofoo, testtest(testtest( - foofoo, - )), testsa) + testtest(foofoo, testtest(testtest(foofoo)), testsa) - testtest(foofoo, seee, testtest(testtest( - foofoo, - )), testsa) + testtest(foofoo, seee, testtest(testtest(foofoo)), testsa) useCallable("A", Callable { println("Hello world") }) @@ -54,9 +46,7 @@ fun foo() { useCallable(Callable { println("Hello world") }) - useCallable( - Callable { println("Hello world") }, - ) + useCallable(Callable { println("Hello world") }) useCallable(Callable { println("Hello world") } ) @@ -78,9 +68,7 @@ fun foo() { useCallable({ println("Hello world") }) - useCallable( - { println("Hello world") }, - ) + useCallable({ println("Hello world") }) useCallable({ println("Hello world") } ) @@ -102,9 +90,7 @@ fun foo() { useCallable(foo() { println("Hello world") }) - useCallable( - foo() { println("Hello world") }, - ) + useCallable(foo() { println("Hello world") }) useCallable(foo() { println("Hello world") } ) @@ -203,9 +189,7 @@ fun foo() { foofoo ) - testtest( - foofoo,/**/ - ) + testtest(foofoo/**/) testtest(foofoo, foofoo, foofoo, foofoo/* */, /* */ bar @@ -218,9 +202,7 @@ fun foo() { foofoo ) - testtest( - foofoo,/**/ - ) + testtest(foofoo/**/) testtest( foofoo, fososos,/* @@ -228,26 +210,16 @@ fun foo() { testtest(testtest(foofoo)), ) - testtest(foofoo, testtest(testtest( - foofoo, - )), /**/testsa) + testtest(foofoo, testtest(testtest(foofoo)), /**/testsa) - testtest(foofoo, testtest(testtest( - foofoo, - ))/* */, /**/testsa) + testtest(foofoo, testtest(testtest(foofoo))/* */, /**/testsa) - testtest(foofoo, testtest(testtest( - foofoo, - ))/* + testtest(foofoo, testtest(testtest(foofoo))/* */, testsa) - testtest(foofoo, seee, testtest(testtest( - foofoo, - )), /**/testsa) + testtest(foofoo, seee, testtest(testtest(foofoo)), /**/testsa) - testtest(foofoo, seee, testtest(testtest( - foofoo, - )), /* + testtest(foofoo, seee, testtest(testtest(foofoo)), /* */testsa) useCallable("B", "C", Callable { @@ -258,4 +230,37 @@ fun foo() { useCallable(Callable { println("Hello world") } // ffd ) + + useCallable( + object : Callable { + override fun call() { + println("Hello world") + } + }, + ) + + useCallable( + foo() { + println("Hello world") + }, + ) + + useCallable( + { + println("Hello world") + }, + ) + + useCallable( + Callable { println("Hello world") }, + ) + + testtest(foofoo, testtest(testtest( + foofoo, + )), testsa) + + testtest( + foofoo, fososos, testtest(testtest(foofoo)), + ) + } \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.after.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.after.kt index c6ebace8056..24a9a5e3adc 100644 --- a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.after.kt +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.after.kt @@ -32,35 +32,15 @@ fun foo() { foofoo, ) - testtest( - foofoo, - ) + testtest(foofoo) testtest(foofoo, testtest(testtest(foofoo))) - testtest( - foofoo, fososos, testtest(testtest(foofoo)), - ) + testtest(foofoo, fososos, testtest(testtest(foofoo))) - testtest( - foofoo, - testtest( - testtest( - foofoo, - ), - ), - testsa, - ) + testtest(foofoo, testtest(testtest(foofoo)), testsa) - testtest( - foofoo, seee, - testtest( - testtest( - foofoo, - ), - ), - testsa, - ) + testtest(foofoo, seee, testtest(testtest(foofoo)), testsa) useCallable("A", Callable { println("Hello world") }) @@ -76,9 +56,7 @@ fun foo() { useCallable(Callable { println("Hello world") }) - useCallable( - Callable { println("Hello world") }, - ) + useCallable(Callable { println("Hello world") }) useCallable( Callable { println("Hello world") }, @@ -106,9 +84,7 @@ fun foo() { useCallable({ println("Hello world") }) - useCallable( - { println("Hello world") }, - ) + useCallable({ println("Hello world") }) useCallable( { println("Hello world") }, @@ -136,9 +112,7 @@ fun foo() { useCallable(foo() { println("Hello world") }) - useCallable( - foo() { println("Hello world") }, - ) + useCallable(foo() { println("Hello world") }) useCallable( foo() { println("Hello world") }, @@ -266,9 +240,7 @@ fun foo() { foofoo, ) - testtest( - foofoo,/**/ - ) + testtest(foofoo/**/) testtest( foofoo, foofoo, foofoo, @@ -286,9 +258,7 @@ fun foo() { foofoo, ) - testtest( - foofoo,/**/ - ) + testtest(foofoo/**/) testtest( foofoo, fososos,/* @@ -296,54 +266,21 @@ fun foo() { testtest(testtest(foofoo)), ) - testtest( - foofoo, - testtest( - testtest( - foofoo, - ), - ), /**/ - testsa, - ) + testtest(foofoo, testtest(testtest(foofoo)), /**/testsa) + + testtest(foofoo, testtest(testtest(foofoo))/* */, /**/testsa) testtest( foofoo, - testtest( - testtest( - foofoo, - ), - ),/* */ /**/ - testsa, - ) - - testtest( - foofoo, - testtest( - testtest( - foofoo, - ), - ),/* + testtest(testtest(foofoo)),/* */ testsa, ) - testtest( - foofoo, seee, - testtest( - testtest( - foofoo, - ), - ), /**/ - testsa, - ) + testtest(foofoo, seee, testtest(testtest(foofoo)), /**/testsa) testtest( - foofoo, seee, - testtest( - testtest( - foofoo, - ), - ), /* + foofoo, seee, testtest(testtest(foofoo)), /* */ testsa, ) @@ -361,4 +298,43 @@ fun foo() { useCallable( Callable { println("Hello world") }, // ffd ) + + useCallable( + object : Callable { + override fun call() { + println("Hello world") + } + }, + ) + + useCallable( + foo() { + println("Hello world") + }, + ) + + useCallable( + { + println("Hello world") + }, + ) + + useCallable( + Callable { println("Hello world") }, + ) + + testtest( + foofoo, + testtest( + testtest( + foofoo, + ), + ), + testsa, + ) + + testtest( + foofoo, fososos, testtest(testtest(foofoo)), + ) + } \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.kt index 0fcd7e966f3..3458ca206ed 100644 --- a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.kt +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.kt @@ -197,4 +197,23 @@ fun foo() { useCallable(Callable { println("Hello world") } // ffd ) + + useCallable(object : Callable { override fun call() { println("Hello world") } + },) + + useCallable(foo() { println("Hello world") + },) + + useCallable({ + println("Hello world") },) + + useCallable(Callable { println("Hello world") } + ,) + + testtest(foofoo, testtest(testtest( + foofoo,)), testsa) + + testtest(foofoo, fososos, testtest(testtest(foofoo)) + ,) + } \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.after.inv.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.after.inv.kt index 564965bf42a..531978d3516 100644 --- a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.after.inv.kt +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.after.inv.kt @@ -50,9 +50,7 @@ fun foo() { foofoo ) - testtest( - foofoo, - ) + testtest(foofoo) testtest(foofoo, testtest(testtest(foofoo))) @@ -64,16 +62,12 @@ fun foo() { ) testtest(foofoo, - testtest(testtest( - foofoo, - )), + testtest(testtest(foofoo)), testsa) testtest(foofoo, seee, - testtest(testtest( - foofoo, - )), + testtest(testtest(foofoo)), testsa) useCallable("A", @@ -90,9 +84,7 @@ fun foo() { useCallable(Callable { println("Hello world") }) - useCallable( - Callable { println("Hello world") }, - ) + useCallable(Callable { println("Hello world") }) useCallable(Callable { println("Hello world") } ) @@ -118,9 +110,7 @@ fun foo() { useCallable({ println("Hello world") }) - useCallable( - { println("Hello world") }, - ) + useCallable({ println("Hello world") }) useCallable({ println("Hello world") } ) @@ -146,9 +136,7 @@ fun foo() { useCallable(foo() { println("Hello world") }) - useCallable( - foo() { println("Hello world") }, - ) + useCallable(foo() { println("Hello world") }) useCallable(foo() { println("Hello world") } ) @@ -270,9 +258,7 @@ fun foo() { foofoo ) - testtest( - foofoo,/**/ - ) + testtest(foofoo/**/) testtest(foofoo, foofoo, @@ -289,9 +275,7 @@ fun foo() { foofoo ) - testtest( - foofoo,/**/ - ) + testtest(foofoo/**/) testtest( foofoo, @@ -301,36 +285,26 @@ fun foo() { ) testtest(foofoo, - testtest(testtest( - foofoo, - )), /**/ + testtest(testtest(foofoo)), /**/ testsa) testtest(foofoo, - testtest(testtest( - foofoo, - ))/* */, /**/ + testtest(testtest(foofoo))/* */, /**/ testsa) testtest(foofoo, - testtest(testtest( - foofoo, - ))/* + testtest(testtest(foofoo))/* */, testsa) testtest(foofoo, seee, - testtest(testtest( - foofoo, - )), /**/ + testtest(testtest(foofoo)), /**/ testsa) testtest(foofoo, seee, - testtest(testtest( - foofoo, - )), /* + testtest(testtest(foofoo)), /* */ testsa) @@ -345,4 +319,41 @@ fun foo() { useCallable(Callable { println("Hello world") } // ffd ) + + useCallable( + object : Callable { + override fun call() { + println("Hello world") + } + }, + ) + + useCallable( + foo() { + println("Hello world") + }, + ) + + useCallable( + { + println("Hello world") + }, + ) + + useCallable( + Callable { println("Hello world") }, + ) + + testtest(foofoo, + testtest(testtest( + foofoo, + )), + testsa) + + testtest( + foofoo, + fososos, + testtest(testtest(foofoo)), + ) + } \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.after.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.after.kt index a927519e569..6b6ea4d3edf 100644 --- a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.after.kt +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.after.kt @@ -56,9 +56,7 @@ fun foo() { foofoo, ) - testtest( - foofoo, - ) + testtest(foofoo) testtest( foofoo, @@ -73,22 +71,14 @@ fun foo() { testtest( foofoo, - testtest( - testtest( - foofoo, - ), - ), + testtest(testtest(foofoo)), testsa, ) testtest( foofoo, seee, - testtest( - testtest( - foofoo, - ), - ), + testtest(testtest(foofoo)), testsa, ) @@ -110,9 +100,7 @@ fun foo() { useCallable(Callable { println("Hello world") }) - useCallable( - Callable { println("Hello world") }, - ) + useCallable(Callable { println("Hello world") }) useCallable( Callable { println("Hello world") }, @@ -144,9 +132,7 @@ fun foo() { useCallable({ println("Hello world") }) - useCallable( - { println("Hello world") }, - ) + useCallable({ println("Hello world") }) useCallable( { println("Hello world") }, @@ -178,9 +164,7 @@ fun foo() { useCallable(foo() { println("Hello world") }) - useCallable( - foo() { println("Hello world") }, - ) + useCallable(foo() { println("Hello world") }) useCallable( foo() { println("Hello world") }, @@ -325,9 +309,7 @@ fun foo() { foofoo, ) - testtest( - foofoo,/**/ - ) + testtest(foofoo/**/) testtest( foofoo, @@ -347,9 +329,7 @@ fun foo() { foofoo, ) - testtest( - foofoo,/**/ - ) + testtest(foofoo/**/) testtest( foofoo, @@ -360,31 +340,19 @@ fun foo() { testtest( foofoo, - testtest( - testtest( - foofoo, - ), - ), /**/ + testtest(testtest(foofoo)), /**/ testsa, ) testtest( foofoo, - testtest( - testtest( - foofoo, - ), - ),/* */ /**/ + testtest(testtest(foofoo)),/* */ /**/ testsa, ) testtest( foofoo, - testtest( - testtest( - foofoo, - ), - ),/* + testtest(testtest(foofoo)),/* */ testsa, ) @@ -392,22 +360,14 @@ fun foo() { testtest( foofoo, seee, - testtest( - testtest( - foofoo, - ), - ), /**/ + testtest(testtest(foofoo)), /**/ testsa, ) testtest( foofoo, seee, - testtest( - testtest( - foofoo, - ), - ), /* + testtest(testtest(foofoo)), /* */ testsa, ) @@ -426,4 +386,45 @@ fun foo() { useCallable( Callable { println("Hello world") }, // ffd ) + + useCallable( + object : Callable { + override fun call() { + println("Hello world") + } + }, + ) + + useCallable( + foo() { + println("Hello world") + }, + ) + + useCallable( + { + println("Hello world") + }, + ) + + useCallable( + Callable { println("Hello world") }, + ) + + testtest( + foofoo, + testtest( + testtest( + foofoo, + ), + ), + testsa, + ) + + testtest( + foofoo, + fososos, + testtest(testtest(foofoo)), + ) + } \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.kt index 41f911654eb..26d8901684b 100644 --- a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.kt +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.kt @@ -205,4 +205,23 @@ fun foo() { useCallable(Callable { println("Hello world") } // ffd ) + + useCallable(object : Callable { override fun call() { println("Hello world") } + },) + + useCallable(foo() { println("Hello world") + },) + + useCallable({ + println("Hello world") },) + + useCallable(Callable { println("Hello world") } + ,) + + testtest(foofoo, testtest(testtest( + foofoo,)), testsa) + + testtest(foofoo, fososos, testtest(testtest(foofoo)) + ,) + } \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.after.inv.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.after.inv.kt index d1e53a1bcd1..4a46d008266 100644 --- a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.after.inv.kt +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.after.inv.kt @@ -26,23 +26,15 @@ fun foo() { foofoo ) - testtest( - foofoo, - ) + testtest(foofoo) testtest(foofoo, testtest(testtest(foofoo))) - testtest( - foofoo, fososos, testtest(testtest(foofoo)), - ) + testtest(foofoo, fososos, testtest(testtest(foofoo))) - testtest(foofoo, testtest(testtest( - foofoo, - )), testsa) + testtest(foofoo, testtest(testtest(foofoo)), testsa) - testtest(foofoo, seee, testtest(testtest( - foofoo, - )), testsa) + testtest(foofoo, seee, testtest(testtest(foofoo)), testsa) useCallable("A", Callable { println("Hello world") }) @@ -54,9 +46,7 @@ fun foo() { useCallable(Callable { println("Hello world") }) - useCallable( - Callable { println("Hello world") }, - ) + useCallable(Callable { println("Hello world") }) useCallable(Callable { println("Hello world") } ) @@ -78,9 +68,7 @@ fun foo() { useCallable({ println("Hello world") }) - useCallable( - { println("Hello world") }, - ) + useCallable({ println("Hello world") }) useCallable({ println("Hello world") } ) @@ -102,9 +90,7 @@ fun foo() { useCallable(foo() { println("Hello world") }) - useCallable( - foo() { println("Hello world") }, - ) + useCallable(foo() { println("Hello world") }) useCallable(foo() { println("Hello world") } ) @@ -203,9 +189,7 @@ fun foo() { foofoo ) - testtest( - foofoo,/**/ - ) + testtest(foofoo/**/) testtest(foofoo, foofoo, foofoo, foofoo/* */, /* */ bar @@ -218,9 +202,7 @@ fun foo() { foofoo ) - testtest( - foofoo,/**/ - ) + testtest(foofoo/**/) testtest( foofoo, fososos,/* @@ -228,26 +210,16 @@ fun foo() { testtest(testtest(foofoo)), ) - testtest(foofoo, testtest(testtest( - foofoo, - )), /**/testsa) + testtest(foofoo, testtest(testtest(foofoo)), /**/testsa) - testtest(foofoo, testtest(testtest( - foofoo, - ))/* */, /**/testsa) + testtest(foofoo, testtest(testtest(foofoo))/* */, /**/testsa) - testtest(foofoo, testtest(testtest( - foofoo, - ))/* + testtest(foofoo, testtest(testtest(foofoo))/* */, testsa) - testtest(foofoo, seee, testtest(testtest( - foofoo, - )), /**/testsa) + testtest(foofoo, seee, testtest(testtest(foofoo)), /**/testsa) - testtest(foofoo, seee, testtest(testtest( - foofoo, - )), /* + testtest(foofoo, seee, testtest(testtest(foofoo)), /* */testsa) useCallable("B", "C", Callable { @@ -258,4 +230,37 @@ fun foo() { useCallable(Callable { println("Hello world") } // ffd ) + + useCallable( + object : Callable { + override fun call() { + println("Hello world") + } + }, + ) + + useCallable( + foo() { + println("Hello world") + }, + ) + + useCallable( + { + println("Hello world") + }, + ) + + useCallable( + Callable { println("Hello world") }, + ) + + testtest(foofoo, testtest(testtest( + foofoo, + )), testsa) + + testtest( + foofoo, fososos, testtest(testtest(foofoo)), + ) + } \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.after.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.after.kt index 0c3dc1bb67a..5410484d4be 100644 --- a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.after.kt +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.after.kt @@ -32,35 +32,15 @@ fun foo() { foofoo, ) - testtest( - foofoo, - ) + testtest(foofoo) testtest(foofoo, testtest(testtest(foofoo))) - testtest( - foofoo, fososos, testtest(testtest(foofoo)), - ) + testtest(foofoo, fososos, testtest(testtest(foofoo))) - testtest( - foofoo, - testtest( - testtest( - foofoo, - ), - ), - testsa, - ) + testtest(foofoo, testtest(testtest(foofoo)), testsa) - testtest( - foofoo, seee, - testtest( - testtest( - foofoo, - ), - ), - testsa, - ) + testtest(foofoo, seee, testtest(testtest(foofoo)), testsa) useCallable("A", Callable { println("Hello world") }) @@ -76,9 +56,7 @@ fun foo() { useCallable(Callable { println("Hello world") }) - useCallable( - Callable { println("Hello world") }, - ) + useCallable(Callable { println("Hello world") }) useCallable( Callable { println("Hello world") }, @@ -106,9 +84,7 @@ fun foo() { useCallable({ println("Hello world") }) - useCallable( - { println("Hello world") }, - ) + useCallable({ println("Hello world") }) useCallable( { println("Hello world") }, @@ -136,9 +112,7 @@ fun foo() { useCallable(foo() { println("Hello world") }) - useCallable( - foo() { println("Hello world") }, - ) + useCallable(foo() { println("Hello world") }) useCallable( foo() { println("Hello world") }, @@ -266,9 +240,7 @@ fun foo() { foofoo, ) - testtest( - foofoo,/**/ - ) + testtest(foofoo/**/) testtest( foofoo, foofoo, foofoo, @@ -286,9 +258,7 @@ fun foo() { foofoo, ) - testtest( - foofoo,/**/ - ) + testtest(foofoo/**/) testtest( foofoo, fososos,/* @@ -296,54 +266,21 @@ fun foo() { testtest(testtest(foofoo)), ) - testtest( - foofoo, - testtest( - testtest( - foofoo, - ), - ), /**/ - testsa, - ) + testtest(foofoo, testtest(testtest(foofoo)), /**/testsa) + + testtest(foofoo, testtest(testtest(foofoo))/* */, /**/testsa) testtest( foofoo, - testtest( - testtest( - foofoo, - ), - ),/* */ /**/ - testsa, - ) - - testtest( - foofoo, - testtest( - testtest( - foofoo, - ), - ),/* + testtest(testtest(foofoo)),/* */ testsa, ) - testtest( - foofoo, seee, - testtest( - testtest( - foofoo, - ), - ), /**/ - testsa, - ) + testtest(foofoo, seee, testtest(testtest(foofoo)), /**/testsa) testtest( - foofoo, seee, - testtest( - testtest( - foofoo, - ), - ), /* + foofoo, seee, testtest(testtest(foofoo)), /* */ testsa, ) @@ -361,4 +298,43 @@ fun foo() { useCallable( Callable { println("Hello world") }, // ffd ) + + useCallable( + object : Callable { + override fun call() { + println("Hello world") + } + }, + ) + + useCallable( + foo() { + println("Hello world") + }, + ) + + useCallable( + { + println("Hello world") + }, + ) + + useCallable( + Callable { println("Hello world") }, + ) + + testtest( + foofoo, + testtest( + testtest( + foofoo, + ), + ), + testsa, + ) + + testtest( + foofoo, fososos, testtest(testtest(foofoo)), + ) + } \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.kt index 978e583dbf8..022ef85b1bf 100644 --- a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.kt +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.kt @@ -197,4 +197,23 @@ fun foo() { useCallable(Callable { println("Hello world") } // ffd ) + + useCallable(object : Callable { override fun call() { println("Hello world") } + },) + + useCallable(foo() { println("Hello world") + },) + + useCallable({ + println("Hello world") },) + + useCallable(Callable { println("Hello world") } + ,) + + testtest(foofoo, testtest(testtest( + foofoo,)), testsa) + + testtest(foofoo, fososos, testtest(testtest(foofoo)) + ,) + } \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueParameters/LambdaValueParameters.after.inv.kt b/idea/testData/formatter/trailingComma/valueParameters/LambdaValueParameters.after.inv.kt index 3a99ab882d1..78b6b7e4250 100644 --- a/idea/testData/formatter/trailingComma/valueParameters/LambdaValueParameters.after.inv.kt +++ b/idea/testData/formatter/trailingComma/valueParameters/LambdaValueParameters.after.inv.kt @@ -17,6 +17,10 @@ fun main() { 10 } + val x: (y: Comparable>, z: Iterable>) -> Int = { + 10 + } + val x: ( y: Comparable>, z: Iterable>, ) -> Int = { @@ -27,9 +31,7 @@ fun main() { 10 } - val x: ( - y: Comparable>, - ) -> Int = { + val x: (y: Comparable>) -> Int = { 10 } @@ -69,9 +71,7 @@ fun main() { 10 } - val x: ( - y: Comparable>,/**/ - ) -> Int = { + val x: (y: Comparable>/**/) -> Int = { 10 } diff --git a/idea/testData/formatter/trailingComma/valueParameters/LambdaValueParameters.after.kt b/idea/testData/formatter/trailingComma/valueParameters/LambdaValueParameters.after.kt index 07d0c244eb8..9b64ba8f1cb 100644 --- a/idea/testData/formatter/trailingComma/valueParameters/LambdaValueParameters.after.kt +++ b/idea/testData/formatter/trailingComma/valueParameters/LambdaValueParameters.after.kt @@ -17,6 +17,10 @@ fun main() { 10 } + val x: (y: Comparable>, z: Iterable>) -> Int = { + 10 + } + val x: ( y: Comparable>, z: Iterable>, ) -> Int = { @@ -27,9 +31,7 @@ fun main() { 10 } - val x: ( - y: Comparable>, - ) -> Int = { + val x: (y: Comparable>) -> Int = { 10 } @@ -73,9 +75,7 @@ fun main() { 10 } - val x: ( - y: Comparable>,/**/ - ) -> Int = { + val x: (y: Comparable>/**/) -> Int = { 10 } diff --git a/idea/testData/formatter/trailingComma/valueParameters/LambdaValueParameters.kt b/idea/testData/formatter/trailingComma/valueParameters/LambdaValueParameters.kt index 0a120e35bbc..0264258d28d 100644 --- a/idea/testData/formatter/trailingComma/valueParameters/LambdaValueParameters.kt +++ b/idea/testData/formatter/trailingComma/valueParameters/LambdaValueParameters.kt @@ -21,6 +21,11 @@ fun main() { 10 } + val x: (y: Comparable>, z: Iterable>, + ) -> Int = { + 10 + } + val x: (y: Comparable>) -> Int = { 10 } diff --git a/idea/testData/formatter/trailingComma/valueParameters/ParameterListChopAsNeeded.after.inv.kt b/idea/testData/formatter/trailingComma/valueParameters/ParameterListChopAsNeeded.after.inv.kt index 35934c0e10a..8de93a9826f 100644 --- a/idea/testData/formatter/trailingComma/valueParameters/ParameterListChopAsNeeded.after.inv.kt +++ b/idea/testData/formatter/trailingComma/valueParameters/ParameterListChopAsNeeded.after.inv.kt @@ -117,9 +117,7 @@ class D2 { class A3 { val x: String - constructor( - x: String, - ) { + constructor(x: String) { this.x = x } } @@ -306,15 +304,11 @@ val foo5: (Int) -> Int = fun( x ): Int = 42 -val foo6: (Int) -> Int = fun( - x, -): Int = 42 +val foo6: (Int) -> Int = fun(x): Int = 42 val foo7: (Int) -> Int = fun(x): Int = 42 -val foo8: (Int, Int, Int) -> Int = fun( - x, y: Int, z, -): Int { +val foo8: (Int, Int, Int) -> Int = fun(x, y: Int, z): Int { return x + y } diff --git a/idea/testData/formatter/trailingComma/valueParameters/ParameterListChopAsNeeded.after.kt b/idea/testData/formatter/trailingComma/valueParameters/ParameterListChopAsNeeded.after.kt index 9edfc179026..60b8f4371b3 100644 --- a/idea/testData/formatter/trailingComma/valueParameters/ParameterListChopAsNeeded.after.kt +++ b/idea/testData/formatter/trailingComma/valueParameters/ParameterListChopAsNeeded.after.kt @@ -117,9 +117,7 @@ class D2 { class A3 { val x: String - constructor( - x: String, - ) { + constructor(x: String) { this.x = x } } @@ -309,15 +307,11 @@ val foo5: (Int) -> Int = fun( x, ): Int = 42 -val foo6: (Int) -> Int = fun( - x, -): Int = 42 +val foo6: (Int) -> Int = fun(x): Int = 42 val foo7: (Int) -> Int = fun(x): Int = 42 -val foo8: (Int, Int, Int) -> Int = fun( - x, y: Int, z, -): Int { +val foo8: (Int, Int, Int) -> Int = fun(x, y: Int, z): Int { return x + y } diff --git a/idea/testData/formatter/trailingComma/valueParameters/ParameterListDoNotWrap.after.inv.kt b/idea/testData/formatter/trailingComma/valueParameters/ParameterListDoNotWrap.after.inv.kt index 77e56e386a2..86faee00bfb 100644 --- a/idea/testData/formatter/trailingComma/valueParameters/ParameterListDoNotWrap.after.inv.kt +++ b/idea/testData/formatter/trailingComma/valueParameters/ParameterListDoNotWrap.after.inv.kt @@ -117,9 +117,7 @@ class D2 { class A3 { val x: String - constructor( - x: String, - ) { + constructor(x: String) { this.x = x } } @@ -306,15 +304,11 @@ val foo5: (Int) -> Int = fun( x ): Int = 42 -val foo6: (Int) -> Int = fun( - x, -): Int = 42 +val foo6: (Int) -> Int = fun(x): Int = 42 val foo7: (Int) -> Int = fun(x): Int = 42 -val foo8: (Int, Int, Int) -> Int = fun( - x, y: Int, z, -): Int { +val foo8: (Int, Int, Int) -> Int = fun(x, y: Int, z): Int { return x + y } diff --git a/idea/testData/formatter/trailingComma/valueParameters/ParameterListDoNotWrap.after.kt b/idea/testData/formatter/trailingComma/valueParameters/ParameterListDoNotWrap.after.kt index dc57816be96..2dfb9e8ce98 100644 --- a/idea/testData/formatter/trailingComma/valueParameters/ParameterListDoNotWrap.after.kt +++ b/idea/testData/formatter/trailingComma/valueParameters/ParameterListDoNotWrap.after.kt @@ -117,9 +117,7 @@ class D2 { class A3 { val x: String - constructor( - x: String, - ) { + constructor(x: String) { this.x = x } } @@ -309,15 +307,11 @@ val foo5: (Int) -> Int = fun( x, ): Int = 42 -val foo6: (Int) -> Int = fun( - x, -): Int = 42 +val foo6: (Int) -> Int = fun(x): Int = 42 val foo7: (Int) -> Int = fun(x): Int = 42 -val foo8: (Int, Int, Int) -> Int = fun( - x, y: Int, z, -): Int { +val foo8: (Int, Int, Int) -> Int = fun(x, y: Int, z): Int { return x + y } diff --git a/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAlways.after.inv.kt b/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAlways.after.inv.kt index 0b1445e0a06..e7160f77445 100644 --- a/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAlways.after.inv.kt +++ b/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAlways.after.inv.kt @@ -117,9 +117,7 @@ class D2 { class A3 { val x: String - constructor( - x: String, - ) { + constructor(x: String) { this.x = x } } @@ -315,9 +313,7 @@ val foo5: (Int) -> Int = fun( x ): Int = 42 -val foo6: (Int) -> Int = fun( - x, -): Int = 42 +val foo6: (Int) -> Int = fun(x): Int = 42 val foo7: (Int) -> Int = fun(x): Int = 42 diff --git a/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAlways.after.kt b/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAlways.after.kt index 815244a547c..401f2caf309 100644 --- a/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAlways.after.kt +++ b/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAlways.after.kt @@ -117,9 +117,7 @@ class D2 { class A3 { val x: String - constructor( - x: String, - ) { + constructor(x: String) { this.x = x } } @@ -316,9 +314,7 @@ val foo5: (Int) -> Int = fun( x, ): Int = 42 -val foo6: (Int) -> Int = fun( - x, -): Int = 42 +val foo6: (Int) -> Int = fun(x): Int = 42 val foo7: (Int) -> Int = fun(x): Int = 42 diff --git a/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAsNeeded.after.inv.kt b/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAsNeeded.after.inv.kt index da7f6646487..cbab4d9d86b 100644 --- a/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAsNeeded.after.inv.kt +++ b/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAsNeeded.after.inv.kt @@ -117,9 +117,7 @@ class D2 { class A3 { val x: String - constructor( - x: String, - ) { + constructor(x: String) { this.x = x } } @@ -306,15 +304,11 @@ val foo5: (Int) -> Int = fun( x ): Int = 42 -val foo6: (Int) -> Int = fun( - x, -): Int = 42 +val foo6: (Int) -> Int = fun(x): Int = 42 val foo7: (Int) -> Int = fun(x): Int = 42 -val foo8: (Int, Int, Int) -> Int = fun( - x, y: Int, z, -): Int { +val foo8: (Int, Int, Int) -> Int = fun(x, y: Int, z): Int { return x + y } diff --git a/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAsNeeded.after.kt b/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAsNeeded.after.kt index b8506d98db6..6d7936aa2ca 100644 --- a/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAsNeeded.after.kt +++ b/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAsNeeded.after.kt @@ -117,9 +117,7 @@ class D2 { class A3 { val x: String - constructor( - x: String, - ) { + constructor(x: String) { this.x = x } } @@ -309,15 +307,11 @@ val foo5: (Int) -> Int = fun( x, ): Int = 42 -val foo6: (Int) -> Int = fun( - x, -): Int = 42 +val foo6: (Int) -> Int = fun(x): Int = 42 val foo7: (Int) -> Int = fun(x): Int = 42 -val foo8: (Int, Int, Int) -> Int = fun( - x, y: Int, z, -): Int { +val foo8: (Int, Int, Int) -> Int = fun(x, y: Int, z): Int { return x + y } diff --git a/idea/testData/formatter/trailingComma/whenEntry/WhenEntry.after.inv.kt b/idea/testData/formatter/trailingComma/whenEntry/WhenEntry.after.inv.kt index d18d2181f73..ba25bd1d7cd 100644 --- a/idea/testData/formatter/trailingComma/whenEntry/WhenEntry.after.inv.kt +++ b/idea/testData/formatter/trailingComma/whenEntry/WhenEntry.after.inv.kt @@ -6,7 +6,19 @@ fun foo(x: Any) = when (x) { fun foo(x: Any) { when (x) { - Comparable::class, Iterable::class, String::class, /*// trailing comma*/ + Comparable::class, Iterable::class, String::class /*// trailing comma*/ -> println(1) + else -> println(3) + } + + when (x) { + Comparable::class, Iterable::class, + String::class /*// trailing comma*/ -> println(1) + else -> println(3) + } + + when (x) { + Comparable::class, Iterable::class, + String::class, /*// trailing comma*/ -> println(1) else -> println(3) } @@ -24,8 +36,7 @@ fun foo(x: Any) { } when (x) { - 1, - -> { + 1 -> { } else -> println(3) diff --git a/idea/testData/formatter/trailingComma/whenEntry/WhenEntry.after.kt b/idea/testData/formatter/trailingComma/whenEntry/WhenEntry.after.kt index fe5620f873e..6060ecdacf5 100644 --- a/idea/testData/formatter/trailingComma/whenEntry/WhenEntry.after.kt +++ b/idea/testData/formatter/trailingComma/whenEntry/WhenEntry.after.kt @@ -6,7 +6,20 @@ fun foo(x: Any) = when (x) { fun foo(x: Any) { when (x) { - Comparable::class, Iterable::class, String::class, /*// trailing comma*/ + Comparable::class, Iterable::class, String::class /*// trailing comma*/ -> println(1) + else -> println(3) + } + + when (x) { + Comparable::class, Iterable::class, + String::class, /*// trailing comma*/ + -> println(1) + else -> println(3) + } + + when (x) { + Comparable::class, Iterable::class, + String::class, /*// trailing comma*/ -> println(1) else -> println(3) } @@ -24,8 +37,7 @@ fun foo(x: Any) { } when (x) { - 1, - -> { + 1 -> { } else -> println(3) diff --git a/idea/testData/formatter/trailingComma/whenEntry/WhenEntry.kt b/idea/testData/formatter/trailingComma/whenEntry/WhenEntry.kt index d37bfe75938..485c775456f 100644 --- a/idea/testData/formatter/trailingComma/whenEntry/WhenEntry.kt +++ b/idea/testData/formatter/trailingComma/whenEntry/WhenEntry.kt @@ -6,7 +6,19 @@ fun foo(x: Any) = when (x) { fun foo(x: Any) { when (x) { - Comparable::class, Iterable::class, String::class, /*// trailing comma*/ -> println(1) + Comparable::class, Iterable::class, String::class /*// trailing comma*/ -> println(1) + else -> println(3) + } + + when (x) { + Comparable::class, Iterable::class, + String::class /*// trailing comma*/ -> println(1) + else -> println(3) + } + + when (x) { + Comparable::class, Iterable::class, + String::class /*// trailing comma*/, -> println(1) else -> println(3) }