From 262c9e685802b77dca8fa2e046ec949c1005cf1c Mon Sep 17 00:00:00 2001 From: Dmitry Gridin Date: Fri, 22 May 2020 16:43:23 +0700 Subject: [PATCH] TrailingCommaPostFormatProcessor: should work with call-site in limited mode * remove useless comma * format call if comma exists #KT-39079 Fixed --- .../idea/formatter/trailingComma/util.kt | 10 ++-- .../TrailingCommaPostFormatProcessor.kt | 9 +--- .../inspections/TrailingCommaInspection.kt | 2 +- .../idea/intentions/TrailingCommaIntention.kt | 4 +- .../joinLines/JoinWithTrailingCommaHandler.kt | 4 +- ...CollectionLiteralInAnnotation.after.inv.kt | 14 ++--- .../CollectionLiteralInAnnotation.after.kt | 14 ++--- .../indices/IndicesAccess.after.inv.kt | 38 +++++++------- .../indices/IndicesAccess.after.kt | 38 +++++++------- .../TypeArgumentList.after.inv.kt | 22 ++++---- .../typeArguments/TypeArgumentList.after.kt | 22 ++++---- .../ArgumentListChopAsNeeded.after.inv.kt | 48 +++++++++-------- .../ArgumentListChopAsNeeded.after.kt | 48 +++++++++-------- .../ArgumentListDoNotWrap.after.inv.kt | 48 +++++++++-------- .../ArgumentListDoNotWrap.after.kt | 48 +++++++++-------- .../ArgumentListWrapAlways.after.inv.kt | 52 ++++++++++--------- .../ArgumentListWrapAlways.after.kt | 52 ++++++++++--------- .../ArgumentListWrapAsNeeded.after.inv.kt | 48 +++++++++-------- .../ArgumentListWrapAsNeeded.after.kt | 48 +++++++++-------- .../formatter/AbstractFormatterTest.java | 9 ++-- .../codeInsight/smartEnter/SmartEnterTest.kt | 2 +- 21 files changed, 301 insertions(+), 279 deletions(-) diff --git a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/trailingComma/util.kt b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/trailingComma/util.kt index 0c6570da837..d687eb64ba8 100644 --- a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/trailingComma/util.kt +++ b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/trailingComma/util.kt @@ -40,14 +40,18 @@ private val TYPES_WITH_TRAILING_COMMA = TokenSet.orSet( TYPES_WITH_TRAILING_COMMA_ON_CALL_SITE, ) -fun UserDataHolder.addTrailingCommaIsAllowedForThis(): Boolean { +fun PsiElement.canAddTrailingCommaWithRegistryCheck(): Boolean { val type = elementType(this) ?: return false return type in TYPES_WITH_TRAILING_COMMA_ON_DECLARATION_SITE || trailingCommaIsAllowedOnCallSite() && type in TYPES_WITH_TRAILING_COMMA_ON_CALL_SITE } -fun KotlinCodeStyleSettings.addTrailingCommaIsAllowedFor(element: UserDataHolder): Boolean = - ALLOW_TRAILING_COMMA && element.addTrailingCommaIsAllowedForThis() +fun KotlinCodeStyleSettings.addTrailingCommaIsAllowedFor(element: UserDataHolder): Boolean = when (elementType(element)) { + null -> false + in TYPES_WITH_TRAILING_COMMA_ON_DECLARATION_SITE -> ALLOW_TRAILING_COMMA + in TYPES_WITH_TRAILING_COMMA_ON_CALL_SITE -> ALLOW_TRAILING_COMMA_ON_CALL_SITE || trailingCommaIsAllowedOnCallSite() + else -> false +} private fun elementType(userDataHolder: UserDataHolder): IElementType? = when (userDataHolder) { is ASTNode -> PsiUtilCore.getElementType(userDataHolder) diff --git a/idea/src/org/jetbrains/kotlin/idea/formatter/TrailingCommaPostFormatProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/formatter/TrailingCommaPostFormatProcessor.kt index 8f785648b03..922f343959b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/formatter/TrailingCommaPostFormatProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/formatter/TrailingCommaPostFormatProcessor.kt @@ -21,7 +21,6 @@ import org.jetbrains.kotlin.idea.formatter.trailingComma.TrailingCommaHelper.fin import org.jetbrains.kotlin.idea.formatter.trailingComma.TrailingCommaHelper.trailingCommaOrLastElement import org.jetbrains.kotlin.idea.formatter.trailingComma.TrailingCommaState import org.jetbrains.kotlin.idea.formatter.trailingComma.addTrailingCommaIsAllowedFor -import org.jetbrains.kotlin.idea.formatter.trailingComma.addTrailingCommaIsAllowedForThis import org.jetbrains.kotlin.idea.util.leafIgnoringWhitespace import org.jetbrains.kotlin.idea.util.leafIgnoringWhitespaceAndComments import org.jetbrains.kotlin.psi.KtElement @@ -40,12 +39,8 @@ class TrailingCommaPostFormatProcessor : PostFormatProcessor { private class TrailingCommaPostFormatVisitor(val settings: CodeStyleSettings) : TrailingCommaVisitor() { private val myPostProcessor = PostFormatProcessorHelper(settings.kotlinCommonSettings) - override fun process(trailingCommaContext: TrailingCommaContext) { - val ktElement = trailingCommaContext.ktElement - if (!ktElement.addTrailingCommaIsAllowedForThis()) return - processIfInRange(ktElement) { - processCommaOwner(trailingCommaContext) - } + override fun process(trailingCommaContext: TrailingCommaContext) = processIfInRange(trailingCommaContext.ktElement) { + processCommaOwner(trailingCommaContext) } private fun processIfInRange(element: KtElement, block: () -> Unit = {}) { diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/TrailingCommaInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/TrailingCommaInspection.kt index e3b526890cd..5e88af55234 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/TrailingCommaInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/TrailingCommaInspection.kt @@ -40,7 +40,7 @@ class TrailingCommaInspection( override fun process(trailingCommaContext: TrailingCommaContext) { val element = trailingCommaContext.ktElement - if (!element.addTrailingCommaIsAllowedForThis()) return + if (!element.canAddTrailingCommaWithRegistryCheck()) return useTrailingComma = CodeStyle.getSettings(element.project).kotlinCustomSettings.ALLOW_TRAILING_COMMA when (trailingCommaContext.state) { diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/TrailingCommaIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/TrailingCommaIntention.kt index 22eb5898d72..aca125fa9a2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/TrailingCommaIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/TrailingCommaIntention.kt @@ -10,7 +10,7 @@ import com.intellij.codeInsight.intention.LowPriorityAction import com.intellij.openapi.editor.Editor import org.jetbrains.kotlin.idea.KotlinBundle import org.jetbrains.kotlin.idea.formatter.kotlinCustomSettings -import org.jetbrains.kotlin.idea.formatter.trailingComma.addTrailingCommaIsAllowedForThis +import org.jetbrains.kotlin.idea.formatter.trailingComma.canAddTrailingCommaWithRegistryCheck import org.jetbrains.kotlin.psi.KtElement class TrailingCommaIntention : SelfTargetingIntention( @@ -22,7 +22,7 @@ class TrailingCommaIntention : SelfTargetingIntention( kotlinCustomSettings.ALLOW_TRAILING_COMMA = !kotlinCustomSettings.ALLOW_TRAILING_COMMA } - override fun isApplicableTo(element: KtElement, caretOffset: Int): Boolean = element.addTrailingCommaIsAllowedForThis().also { + override fun isApplicableTo(element: KtElement, caretOffset: Int): Boolean = element.canAddTrailingCommaWithRegistryCheck().also { val actionNumber = 1.takeIf { CodeStyle.getSettings(element.project).kotlinCustomSettings.ALLOW_TRAILING_COMMA } ?: 0 setTextGetter(KotlinBundle.lazyMessage("intention.trailing.comma.custom.text", actionNumber)) } diff --git a/idea/src/org/jetbrains/kotlin/idea/joinLines/JoinWithTrailingCommaHandler.kt b/idea/src/org/jetbrains/kotlin/idea/joinLines/JoinWithTrailingCommaHandler.kt index eee634a2a06..36af4d6fcef 100644 --- a/idea/src/org/jetbrains/kotlin/idea/joinLines/JoinWithTrailingCommaHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/joinLines/JoinWithTrailingCommaHandler.kt @@ -13,7 +13,7 @@ import com.intellij.psi.codeStyle.CodeStyleManager import org.jetbrains.kotlin.idea.core.util.containsLineBreakInRange import org.jetbrains.kotlin.idea.formatter.trailingComma.TrailingCommaHelper import org.jetbrains.kotlin.idea.formatter.trailingComma.TrailingCommaState -import org.jetbrains.kotlin.idea.formatter.trailingComma.addTrailingCommaIsAllowedForThis +import org.jetbrains.kotlin.idea.formatter.trailingComma.canAddTrailingCommaWithRegistryCheck import org.jetbrains.kotlin.idea.formatter.trailingComma.existsOrMissing import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtFile @@ -26,7 +26,7 @@ class JoinWithTrailingCommaHandler : JoinLinesHandlerDelegate { val commaOwner = file.findElementAt(start) ?.parentsWithSelf ?.filter { !document.containsLineBreakInRange(it.textRange) } - ?.findLast { it.addTrailingCommaIsAllowedForThis() } as? KtElement + ?.findLast { it.canAddTrailingCommaWithRegistryCheck() } as? KtElement ?: return CANNOT_JOIN if (TrailingCommaState.stateForElement(commaOwner).existsOrMissing) return CANNOT_JOIN diff --git a/idea/testData/formatter/trailingComma/collectionLiteralExpression/CollectionLiteralInAnnotation.after.inv.kt b/idea/testData/formatter/trailingComma/collectionLiteralExpression/CollectionLiteralInAnnotation.after.inv.kt index 81244145895..3eeca972c74 100644 --- a/idea/testData/formatter/trailingComma/collectionLiteralExpression/CollectionLiteralInAnnotation.after.inv.kt +++ b/idea/testData/formatter/trailingComma/collectionLiteralExpression/CollectionLiteralInAnnotation.after.inv.kt @@ -3,7 +3,7 @@ @Anno([1]) fun a() = Unit -@Anno([1, ]) +@Anno([1]) fun a() = Unit @Anno([1 @@ -22,7 +22,7 @@ fun a() = Unit @Anno([1, 2]) fun a() = Unit -@Anno([1, 2, ]) +@Anno([1, 2]) fun a() = Unit @Anno([1, 2 @@ -41,7 +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" @@ -74,8 +74,8 @@ fun a() = Unit /* */ // d - 1/* - */,/* + 1,/* + *//* */ ]) fun a() = Unit @@ -91,8 +91,8 @@ fun a() = Unit @Anno([ 1, - 2/* - */,/* + 2,/* + *//* */ ]) fun a() = Unit diff --git a/idea/testData/formatter/trailingComma/collectionLiteralExpression/CollectionLiteralInAnnotation.after.kt b/idea/testData/formatter/trailingComma/collectionLiteralExpression/CollectionLiteralInAnnotation.after.kt index 81244145895..3eeca972c74 100644 --- a/idea/testData/formatter/trailingComma/collectionLiteralExpression/CollectionLiteralInAnnotation.after.kt +++ b/idea/testData/formatter/trailingComma/collectionLiteralExpression/CollectionLiteralInAnnotation.after.kt @@ -3,7 +3,7 @@ @Anno([1]) fun a() = Unit -@Anno([1, ]) +@Anno([1]) fun a() = Unit @Anno([1 @@ -22,7 +22,7 @@ fun a() = Unit @Anno([1, 2]) fun a() = Unit -@Anno([1, 2, ]) +@Anno([1, 2]) fun a() = Unit @Anno([1, 2 @@ -41,7 +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" @@ -74,8 +74,8 @@ fun a() = Unit /* */ // d - 1/* - */,/* + 1,/* + *//* */ ]) fun a() = Unit @@ -91,8 +91,8 @@ fun a() = Unit @Anno([ 1, - 2/* - */,/* + 2,/* + *//* */ ]) fun a() = Unit diff --git a/idea/testData/formatter/trailingComma/indices/IndicesAccess.after.inv.kt b/idea/testData/formatter/trailingComma/indices/IndicesAccess.after.inv.kt index 83ec56e7bc4..ee6fad75cbf 100644 --- a/idea/testData/formatter/trailingComma/indices/IndicesAccess.after.inv.kt +++ b/idea/testData/formatter/trailingComma/indices/IndicesAccess.after.inv.kt @@ -25,7 +25,7 @@ fun foo() { foofoo ] - testtest[foofoo, ] + testtest[foofoo] testtest[foofoo, testtest[testtest[foofoo]]] @@ -34,9 +34,9 @@ fun foo() { 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"] }] @@ -48,7 +48,7 @@ fun foo() { useCallable[Callable { println["Hello world"] }] - useCallable[Callable { println["Hello world"] }, ] + useCallable[Callable { println["Hello world"] }] useCallable[ Callable { @@ -76,7 +76,7 @@ fun foo() { useCallable[{ println["Hello world"] }] - useCallable[{ println["Hello world"] }, ] + useCallable[{ println["Hello world"] }] useCallable[ { println["Hello world"] }, @@ -104,7 +104,7 @@ fun foo() { override fun call() { println["Hello world"] } - }, foo[0, ]] + }, foo[0]] useCallable[object : Callable { override fun call() { @@ -112,11 +112,13 @@ fun foo() { } }] - useCallable[object : Callable { - override fun call() { - println["Hello world"] - } - }, ] + useCallable[ + object : Callable { + override fun call() { + println["Hello world"] + } + }, + ] useCallable[object : Callable { override fun call() { @@ -171,7 +173,7 @@ fun foo() { foofoo ] - testtest[foofoo,/**/] + testtest[foofoo/**/] testtest[foofoo, foofoo, foofoo, foofoo/* */, /* */ bar @@ -184,7 +186,7 @@ fun foo() { foofoo ] - testtest[foofoo,/**/] + testtest[foofoo/**/] testtest[ foofoo, fososos,/* @@ -192,16 +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 83ec56e7bc4..ee6fad75cbf 100644 --- a/idea/testData/formatter/trailingComma/indices/IndicesAccess.after.kt +++ b/idea/testData/formatter/trailingComma/indices/IndicesAccess.after.kt @@ -25,7 +25,7 @@ fun foo() { foofoo ] - testtest[foofoo, ] + testtest[foofoo] testtest[foofoo, testtest[testtest[foofoo]]] @@ -34,9 +34,9 @@ fun foo() { 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"] }] @@ -48,7 +48,7 @@ fun foo() { useCallable[Callable { println["Hello world"] }] - useCallable[Callable { println["Hello world"] }, ] + useCallable[Callable { println["Hello world"] }] useCallable[ Callable { @@ -76,7 +76,7 @@ fun foo() { useCallable[{ println["Hello world"] }] - useCallable[{ println["Hello world"] }, ] + useCallable[{ println["Hello world"] }] useCallable[ { println["Hello world"] }, @@ -104,7 +104,7 @@ fun foo() { override fun call() { println["Hello world"] } - }, foo[0, ]] + }, foo[0]] useCallable[object : Callable { override fun call() { @@ -112,11 +112,13 @@ fun foo() { } }] - useCallable[object : Callable { - override fun call() { - println["Hello world"] - } - }, ] + useCallable[ + object : Callable { + override fun call() { + println["Hello world"] + } + }, + ] useCallable[object : Callable { override fun call() { @@ -171,7 +173,7 @@ fun foo() { foofoo ] - testtest[foofoo,/**/] + testtest[foofoo/**/] testtest[foofoo, foofoo, foofoo, foofoo/* */, /* */ bar @@ -184,7 +186,7 @@ fun foo() { foofoo ] - testtest[foofoo,/**/] + testtest[foofoo/**/] testtest[ foofoo, fososos,/* @@ -192,16 +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/typeArguments/TypeArgumentList.after.inv.kt b/idea/testData/formatter/trailingComma/typeArguments/TypeArgumentList.after.inv.kt index 1a08abdc454..4345cac8a65 100644 --- a/idea/testData/formatter/trailingComma/typeArguments/TypeArgumentList.after.inv.kt +++ b/idea/testData/formatter/trailingComma/typeArguments/TypeArgumentList.after.inv.kt @@ -35,19 +35,19 @@ fun foo() { foofoo >() - testtest() + testtest() testtest>>() - testtest>, >() + testtest>>() testtest< foofoo, fososos, testtest>, >() - testtest>, testsa>() + testtest>, testsa>() - testtest>, testsa>() + testtest>, testsa>() testtest< foofoo, foofoo, foofoo, foofoo, @@ -80,7 +80,7 @@ fun foo() { foofoo >() - testtest() + testtest() testtest() - testtest() + testtest() testtest< foofoo,/* @@ -110,15 +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 1a08abdc454..4345cac8a65 100644 --- a/idea/testData/formatter/trailingComma/typeArguments/TypeArgumentList.after.kt +++ b/idea/testData/formatter/trailingComma/typeArguments/TypeArgumentList.after.kt @@ -35,19 +35,19 @@ fun foo() { foofoo >() - testtest() + testtest() testtest>>() - testtest>, >() + testtest>>() testtest< foofoo, fososos, testtest>, >() - testtest>, testsa>() + testtest>, testsa>() - testtest>, testsa>() + testtest>, testsa>() testtest< foofoo, foofoo, foofoo, foofoo, @@ -80,7 +80,7 @@ fun foo() { foofoo >() - testtest() + testtest() testtest() - testtest() + testtest() testtest< foofoo,/* @@ -110,15 +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/valueArguments/ArgumentListChopAsNeeded.after.inv.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.after.inv.kt index 70971e6e636..6e536ff0ad8 100644 --- a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.after.inv.kt +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.after.inv.kt @@ -26,15 +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") }) @@ -46,7 +46,7 @@ fun foo() { useCallable(Callable { println("Hello world") }) - useCallable(Callable { println("Hello world") }, ) + useCallable(Callable { println("Hello world") }) useCallable(Callable { println("Hello world") } ) @@ -68,7 +68,7 @@ fun foo() { useCallable({ println("Hello world") }) - useCallable({ println("Hello world") }, ) + useCallable({ println("Hello world") }) useCallable({ println("Hello world") } ) @@ -90,7 +90,7 @@ fun foo() { useCallable(foo() { println("Hello world") }) - useCallable(foo() { println("Hello world") }, ) + useCallable(foo() { println("Hello world") }) useCallable(foo() { println("Hello world") } ) @@ -128,11 +128,13 @@ fun foo() { } }) - useCallable(object : Callable { - override fun call() { - println("Hello world") - } - }, ) + useCallable( + object : Callable { + override fun call() { + println("Hello world") + } + }, + ) useCallable(object : Callable { override fun call() { @@ -187,7 +189,7 @@ fun foo() { foofoo ) - testtest(foofoo,/**/) + testtest(foofoo/**/) testtest(foofoo, foofoo, foofoo, foofoo/* */, /* */ bar @@ -200,7 +202,7 @@ fun foo() { foofoo ) - testtest(foofoo,/**/) + testtest(foofoo/**/) testtest( foofoo, fososos,/* @@ -208,16 +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 { @@ -265,9 +267,9 @@ fun foo() { fun test() { baz( - f = fun(it: Int): String = "$it" /*dwdwd - */, - name = "" /* - */, + f = fun(it: Int): String = "$it", /*dwdwd + */ + name = "", /* + */ ) } diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.after.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.after.kt index 70971e6e636..6e536ff0ad8 100644 --- a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.after.kt +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.after.kt @@ -26,15 +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") }) @@ -46,7 +46,7 @@ fun foo() { useCallable(Callable { println("Hello world") }) - useCallable(Callable { println("Hello world") }, ) + useCallable(Callable { println("Hello world") }) useCallable(Callable { println("Hello world") } ) @@ -68,7 +68,7 @@ fun foo() { useCallable({ println("Hello world") }) - useCallable({ println("Hello world") }, ) + useCallable({ println("Hello world") }) useCallable({ println("Hello world") } ) @@ -90,7 +90,7 @@ fun foo() { useCallable(foo() { println("Hello world") }) - useCallable(foo() { println("Hello world") }, ) + useCallable(foo() { println("Hello world") }) useCallable(foo() { println("Hello world") } ) @@ -128,11 +128,13 @@ fun foo() { } }) - useCallable(object : Callable { - override fun call() { - println("Hello world") - } - }, ) + useCallable( + object : Callable { + override fun call() { + println("Hello world") + } + }, + ) useCallable(object : Callable { override fun call() { @@ -187,7 +189,7 @@ fun foo() { foofoo ) - testtest(foofoo,/**/) + testtest(foofoo/**/) testtest(foofoo, foofoo, foofoo, foofoo/* */, /* */ bar @@ -200,7 +202,7 @@ fun foo() { foofoo ) - testtest(foofoo,/**/) + testtest(foofoo/**/) testtest( foofoo, fososos,/* @@ -208,16 +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 { @@ -265,9 +267,9 @@ fun foo() { fun test() { baz( - f = fun(it: Int): String = "$it" /*dwdwd - */, - name = "" /* - */, + f = fun(it: Int): String = "$it", /*dwdwd + */ + name = "", /* + */ ) } diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.after.inv.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.after.inv.kt index 76f77d2f511..a54b1b7e946 100644 --- a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.after.inv.kt +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.after.inv.kt @@ -26,15 +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") }) @@ -46,7 +46,7 @@ fun foo() { useCallable(Callable { println("Hello world") }) - useCallable(Callable { println("Hello world") }, ) + useCallable(Callable { println("Hello world") }) useCallable(Callable { println("Hello world") } ) @@ -68,7 +68,7 @@ fun foo() { useCallable({ println("Hello world") }) - useCallable({ println("Hello world") }, ) + useCallable({ println("Hello world") }) useCallable({ println("Hello world") } ) @@ -90,7 +90,7 @@ fun foo() { useCallable(foo() { println("Hello world") }) - useCallable(foo() { println("Hello world") }, ) + useCallable(foo() { println("Hello world") }) useCallable(foo() { println("Hello world") } ) @@ -128,11 +128,13 @@ fun foo() { } }) - useCallable(object : Callable { - override fun call() { - println("Hello world") - } - }, ) + useCallable( + object : Callable { + override fun call() { + println("Hello world") + } + }, + ) useCallable(object : Callable { override fun call() { @@ -187,7 +189,7 @@ fun foo() { foofoo ) - testtest(foofoo,/**/) + testtest(foofoo/**/) testtest(foofoo, foofoo, foofoo, foofoo/* */, /* */ bar @@ -200,7 +202,7 @@ fun foo() { foofoo ) - testtest(foofoo,/**/) + testtest(foofoo/**/) testtest( foofoo, fososos,/* @@ -208,16 +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 { @@ -265,9 +267,9 @@ fun foo() { fun test() { baz( - f = fun(it: Int): String = "$it" /*dwdwd - */, - name = "" /* - */, + f = fun(it: Int): String = "$it", /*dwdwd + */ + name = "", /* + */ ) } diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.after.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.after.kt index 76f77d2f511..a54b1b7e946 100644 --- a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.after.kt +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.after.kt @@ -26,15 +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") }) @@ -46,7 +46,7 @@ fun foo() { useCallable(Callable { println("Hello world") }) - useCallable(Callable { println("Hello world") }, ) + useCallable(Callable { println("Hello world") }) useCallable(Callable { println("Hello world") } ) @@ -68,7 +68,7 @@ fun foo() { useCallable({ println("Hello world") }) - useCallable({ println("Hello world") }, ) + useCallable({ println("Hello world") }) useCallable({ println("Hello world") } ) @@ -90,7 +90,7 @@ fun foo() { useCallable(foo() { println("Hello world") }) - useCallable(foo() { println("Hello world") }, ) + useCallable(foo() { println("Hello world") }) useCallable(foo() { println("Hello world") } ) @@ -128,11 +128,13 @@ fun foo() { } }) - useCallable(object : Callable { - override fun call() { - println("Hello world") - } - }, ) + useCallable( + object : Callable { + override fun call() { + println("Hello world") + } + }, + ) useCallable(object : Callable { override fun call() { @@ -187,7 +189,7 @@ fun foo() { foofoo ) - testtest(foofoo,/**/) + testtest(foofoo/**/) testtest(foofoo, foofoo, foofoo, foofoo/* */, /* */ bar @@ -200,7 +202,7 @@ fun foo() { foofoo ) - testtest(foofoo,/**/) + testtest(foofoo/**/) testtest( foofoo, fososos,/* @@ -208,16 +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 { @@ -265,9 +267,9 @@ fun foo() { fun test() { baz( - f = fun(it: Int): String = "$it" /*dwdwd - */, - name = "" /* - */, + f = fun(it: Int): String = "$it", /*dwdwd + */ + name = "", /* + */ ) } diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.after.inv.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.after.inv.kt index 823ffb15464..54e78b87315 100644 --- a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.after.inv.kt +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.after.inv.kt @@ -50,22 +50,24 @@ fun foo() { foofoo ) - testtest(foofoo, ) + testtest(foofoo) testtest(foofoo, testtest(testtest(foofoo))) - testtest(foofoo, + testtest( + foofoo, fososos, - testtest(testtest(foofoo)), ) + testtest(testtest(foofoo)), + ) testtest(foofoo, - testtest(testtest(foofoo, )), + testtest(testtest(foofoo)), testsa) testtest(foofoo, seee, - testtest(testtest(foofoo, )), + testtest(testtest(foofoo)), testsa) useCallable("A", @@ -82,7 +84,7 @@ fun foo() { useCallable(Callable { println("Hello world") }) - useCallable(Callable { println("Hello world") }, ) + useCallable(Callable { println("Hello world") }) useCallable(Callable { println("Hello world") } ) @@ -108,7 +110,7 @@ fun foo() { useCallable({ println("Hello world") }) - useCallable({ println("Hello world") }, ) + useCallable({ println("Hello world") }) useCallable({ println("Hello world") } ) @@ -134,7 +136,7 @@ fun foo() { useCallable(foo() { println("Hello world") }) - useCallable(foo() { println("Hello world") }, ) + useCallable(foo() { println("Hello world") }) useCallable(foo() { println("Hello world") } ) @@ -177,11 +179,13 @@ fun foo() { } }) - useCallable(object : Callable { - override fun call() { - println("Hello world") - } - }, ) + useCallable( + object : Callable { + override fun call() { + println("Hello world") + } + }, + ) useCallable(object : Callable { override fun call() { @@ -254,7 +258,7 @@ fun foo() { foofoo ) - testtest(foofoo,/**/) + testtest(foofoo/**/) testtest(foofoo, foofoo, @@ -271,7 +275,7 @@ fun foo() { foofoo ) - testtest(foofoo,/**/) + testtest(foofoo/**/) testtest( foofoo, @@ -281,26 +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) @@ -356,9 +360,9 @@ fun foo() { fun test() { baz( - f = fun(it: Int): String = "$it" /*dwdwd - */, - name = "" /* - */, + f = fun(it: Int): String = "$it", /*dwdwd + */ + name = "", /* + */ ) } diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.after.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.after.kt index 823ffb15464..54e78b87315 100644 --- a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.after.kt +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.after.kt @@ -50,22 +50,24 @@ fun foo() { foofoo ) - testtest(foofoo, ) + testtest(foofoo) testtest(foofoo, testtest(testtest(foofoo))) - testtest(foofoo, + testtest( + foofoo, fososos, - testtest(testtest(foofoo)), ) + testtest(testtest(foofoo)), + ) testtest(foofoo, - testtest(testtest(foofoo, )), + testtest(testtest(foofoo)), testsa) testtest(foofoo, seee, - testtest(testtest(foofoo, )), + testtest(testtest(foofoo)), testsa) useCallable("A", @@ -82,7 +84,7 @@ fun foo() { useCallable(Callable { println("Hello world") }) - useCallable(Callable { println("Hello world") }, ) + useCallable(Callable { println("Hello world") }) useCallable(Callable { println("Hello world") } ) @@ -108,7 +110,7 @@ fun foo() { useCallable({ println("Hello world") }) - useCallable({ println("Hello world") }, ) + useCallable({ println("Hello world") }) useCallable({ println("Hello world") } ) @@ -134,7 +136,7 @@ fun foo() { useCallable(foo() { println("Hello world") }) - useCallable(foo() { println("Hello world") }, ) + useCallable(foo() { println("Hello world") }) useCallable(foo() { println("Hello world") } ) @@ -177,11 +179,13 @@ fun foo() { } }) - useCallable(object : Callable { - override fun call() { - println("Hello world") - } - }, ) + useCallable( + object : Callable { + override fun call() { + println("Hello world") + } + }, + ) useCallable(object : Callable { override fun call() { @@ -254,7 +258,7 @@ fun foo() { foofoo ) - testtest(foofoo,/**/) + testtest(foofoo/**/) testtest(foofoo, foofoo, @@ -271,7 +275,7 @@ fun foo() { foofoo ) - testtest(foofoo,/**/) + testtest(foofoo/**/) testtest( foofoo, @@ -281,26 +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) @@ -356,9 +360,9 @@ fun foo() { fun test() { baz( - f = fun(it: Int): String = "$it" /*dwdwd - */, - name = "" /* - */, + f = fun(it: Int): String = "$it", /*dwdwd + */ + name = "", /* + */ ) } diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.after.inv.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.after.inv.kt index 86f8b85db57..5d5ec47e5e8 100644 --- a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.after.inv.kt +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.after.inv.kt @@ -26,15 +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") }) @@ -46,7 +46,7 @@ fun foo() { useCallable(Callable { println("Hello world") }) - useCallable(Callable { println("Hello world") }, ) + useCallable(Callable { println("Hello world") }) useCallable(Callable { println("Hello world") } ) @@ -68,7 +68,7 @@ fun foo() { useCallable({ println("Hello world") }) - useCallable({ println("Hello world") }, ) + useCallable({ println("Hello world") }) useCallable({ println("Hello world") } ) @@ -90,7 +90,7 @@ fun foo() { useCallable(foo() { println("Hello world") }) - useCallable(foo() { println("Hello world") }, ) + useCallable(foo() { println("Hello world") }) useCallable(foo() { println("Hello world") } ) @@ -128,11 +128,13 @@ fun foo() { } }) - useCallable(object : Callable { - override fun call() { - println("Hello world") - } - }, ) + useCallable( + object : Callable { + override fun call() { + println("Hello world") + } + }, + ) useCallable(object : Callable { override fun call() { @@ -187,7 +189,7 @@ fun foo() { foofoo ) - testtest(foofoo,/**/) + testtest(foofoo/**/) testtest(foofoo, foofoo, foofoo, foofoo/* */, /* */ bar @@ -200,7 +202,7 @@ fun foo() { foofoo ) - testtest(foofoo,/**/) + testtest(foofoo/**/) testtest( foofoo, fososos,/* @@ -208,16 +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 { @@ -265,9 +267,9 @@ fun foo() { fun test() { baz( - f = fun(it: Int): String = "$it" /*dwdwd - */, - name = "" /* - */, + f = fun(it: Int): String = "$it", /*dwdwd + */ + name = "", /* + */ ) } diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.after.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.after.kt index 86f8b85db57..5d5ec47e5e8 100644 --- a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.after.kt +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.after.kt @@ -26,15 +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") }) @@ -46,7 +46,7 @@ fun foo() { useCallable(Callable { println("Hello world") }) - useCallable(Callable { println("Hello world") }, ) + useCallable(Callable { println("Hello world") }) useCallable(Callable { println("Hello world") } ) @@ -68,7 +68,7 @@ fun foo() { useCallable({ println("Hello world") }) - useCallable({ println("Hello world") }, ) + useCallable({ println("Hello world") }) useCallable({ println("Hello world") } ) @@ -90,7 +90,7 @@ fun foo() { useCallable(foo() { println("Hello world") }) - useCallable(foo() { println("Hello world") }, ) + useCallable(foo() { println("Hello world") }) useCallable(foo() { println("Hello world") } ) @@ -128,11 +128,13 @@ fun foo() { } }) - useCallable(object : Callable { - override fun call() { - println("Hello world") - } - }, ) + useCallable( + object : Callable { + override fun call() { + println("Hello world") + } + }, + ) useCallable(object : Callable { override fun call() { @@ -187,7 +189,7 @@ fun foo() { foofoo ) - testtest(foofoo,/**/) + testtest(foofoo/**/) testtest(foofoo, foofoo, foofoo, foofoo/* */, /* */ bar @@ -200,7 +202,7 @@ fun foo() { foofoo ) - testtest(foofoo,/**/) + testtest(foofoo/**/) testtest( foofoo, fososos,/* @@ -208,16 +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 { @@ -265,9 +267,9 @@ fun foo() { fun test() { baz( - f = fun(it: Int): String = "$it" /*dwdwd - */, - name = "" /* - */, + f = fun(it: Int): String = "$it", /*dwdwd + */ + name = "", /* + */ ) } diff --git a/idea/tests/org/jetbrains/kotlin/formatter/AbstractFormatterTest.java b/idea/tests/org/jetbrains/kotlin/formatter/AbstractFormatterTest.java index 498aed17135..435806ab32c 100644 --- a/idea/tests/org/jetbrains/kotlin/formatter/AbstractFormatterTest.java +++ b/idea/tests/org/jetbrains/kotlin/formatter/AbstractFormatterTest.java @@ -125,7 +125,7 @@ public abstract class AbstractFormatterTest extends KotlinLightIdeaTestCase { } public void doTestInvertedCallSite(@NotNull String expectedFileNameWithExtension) throws Exception { - doTest(expectedFileNameWithExtension, true, true); + doTest(expectedFileNameWithExtension, true, false); } public void doTestCallSite(@NotNull String expectedFileNameWithExtension) throws Exception { @@ -138,7 +138,7 @@ public abstract class AbstractFormatterTest extends KotlinLightIdeaTestCase { String originalFileText = FileUtil.loadFile(new File(testFileName + testFileExtension), true); CodeStyleSettings codeStyleSettings = CodeStyle.getSettings(getProject_()); - RegistryValue registryValue = Registry.get("kotlin.formatter.allowTrailingCommaOnCallSite"); + KotlinCodeStyleSettings customSettings = codeStyleSettings.getCustomSettings(KotlinCodeStyleSettings.class); try { Integer rightMargin = InTextDirectivesUtils.getPrefixedInt(originalFileText, "// RIGHT_MARGIN: "); if (rightMargin != null) { @@ -147,7 +147,7 @@ public abstract class AbstractFormatterTest extends KotlinLightIdeaTestCase { Boolean trailingComma = InTextDirectivesUtils.getPrefixedBoolean(originalFileText, "// TRAILING_COMMA: "); if (trailingComma != null) { - codeStyleSettings.getCustomSettings(KotlinCodeStyleSettings.class).ALLOW_TRAILING_COMMA = trailingComma; + customSettings.ALLOW_TRAILING_COMMA = trailingComma; } SettingsConfigurator configurator = FormatSettingsUtil.createConfigurator(originalFileText, codeStyleSettings); @@ -158,12 +158,11 @@ public abstract class AbstractFormatterTest extends KotlinLightIdeaTestCase { configurator.configureInvertedSettings(); } - registryValue.setValue(callSite); + customSettings.ALLOW_TRAILING_COMMA_ON_CALL_SITE = callSite; doTextTest(originalFileText, new File(expectedFileNameWithExtension), testFileExtension); } finally { codeStyleSettings.clearCodeStyleSettings(); - registryValue.resetToDefault(); } } } diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/smartEnter/SmartEnterTest.kt b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/smartEnter/SmartEnterTest.kt index 0b421c08ec1..4ced98137b2 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/smartEnter/SmartEnterTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/smartEnter/SmartEnterTest.kt @@ -1435,7 +1435,7 @@ class SmartEnterTest : KotlinLightCodeInsightFixtureTestCase() { """ fun foo(i: Int) = 1 fun test4() { - foo(1,) + foo(1) } """ )