diff --git a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index 259b4918d6e..97ca7ffc395 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -585,10 +585,18 @@ fun main(args: Array) { testClass { model("formatter", pattern = """^([^\.]+)\.after\.kt.*$""") + model( + "formatter/trailingComma", pattern = """^([^\.]+)\.call\.after\.kt.*$""", + testMethod = "doTestCallSite", testClassName = "FormatterCallSite" + ) model( "formatter", pattern = """^([^\.]+)\.after\.inv\.kt.*$""", testMethod = "doTestInverted", testClassName = "FormatterInverted" ) + model( + "formatter/trailingComma", pattern = """^([^\.]+)\.call\.after\.inv\.kt.*$""", + testMethod = "doTestInvertedCallSite", testClassName = "FormatterInvertedCallSite" + ) } testClass { diff --git a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as35 b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as35 index 399e7858931..b7153861e4a 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as35 +++ b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as35 @@ -567,8 +567,18 @@ fun main(args: Array) { testClass { model("formatter", pattern = """^([^\.]+)\.after\.kt.*$""") - model("formatter", pattern = """^([^\.]+)\.after\.inv\.kt.*$""", - testMethod = "doTestInverted", testClassName = "FormatterInverted") + model( + "formatter/trailingComma", pattern = """^([^\.]+)\.call\.after\.kt.*$""", + testMethod = "doTestCallSite", testClassName = "FormatterCallSite" + ) + model( + "formatter", pattern = """^([^\.]+)\.after\.inv\.kt.*$""", + testMethod = "doTestInverted", testClassName = "FormatterInverted" + ) + model( + "formatter/trailingComma", pattern = """^([^\.]+)\.call\.after\.inv\.kt.*$""", + testMethod = "doTestInvertedCallSite", testClassName = "FormatterInvertedCallSite" + ) } testClass { diff --git a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as36 b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as36 index 399e7858931..b7153861e4a 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as36 +++ b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as36 @@ -567,8 +567,18 @@ fun main(args: Array) { testClass { model("formatter", pattern = """^([^\.]+)\.after\.kt.*$""") - model("formatter", pattern = """^([^\.]+)\.after\.inv\.kt.*$""", - testMethod = "doTestInverted", testClassName = "FormatterInverted") + model( + "formatter/trailingComma", pattern = """^([^\.]+)\.call\.after\.kt.*$""", + testMethod = "doTestCallSite", testClassName = "FormatterCallSite" + ) + model( + "formatter", pattern = """^([^\.]+)\.after\.inv\.kt.*$""", + testMethod = "doTestInverted", testClassName = "FormatterInverted" + ) + model( + "formatter/trailingComma", pattern = """^([^\.]+)\.call\.after\.inv\.kt.*$""", + testMethod = "doTestInvertedCallSite", testClassName = "FormatterInvertedCallSite" + ) } testClass { diff --git a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as40 b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as40 index 399e7858931..b7153861e4a 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as40 +++ b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as40 @@ -567,8 +567,18 @@ fun main(args: Array) { testClass { model("formatter", pattern = """^([^\.]+)\.after\.kt.*$""") - model("formatter", pattern = """^([^\.]+)\.after\.inv\.kt.*$""", - testMethod = "doTestInverted", testClassName = "FormatterInverted") + model( + "formatter/trailingComma", pattern = """^([^\.]+)\.call\.after\.kt.*$""", + testMethod = "doTestCallSite", testClassName = "FormatterCallSite" + ) + model( + "formatter", pattern = """^([^\.]+)\.after\.inv\.kt.*$""", + testMethod = "doTestInverted", testClassName = "FormatterInverted" + ) + model( + "formatter/trailingComma", pattern = """^([^\.]+)\.call\.after\.inv\.kt.*$""", + testMethod = "doTestInvertedCallSite", testClassName = "FormatterInvertedCallSite" + ) } testClass { 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 086a24fc5da..ecdcc2c1c30 100644 --- a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt +++ b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt @@ -19,10 +19,7 @@ import com.intellij.psi.tree.TokenSet import org.jetbrains.kotlin.KtNodeTypes.* import org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings import org.jetbrains.kotlin.idea.formatter.NodeIndentStrategy.Companion.strategy -import org.jetbrains.kotlin.idea.util.containsLineBreakInThis -import org.jetbrains.kotlin.idea.util.isMultiline -import org.jetbrains.kotlin.idea.util.needTrailingComma -import org.jetbrains.kotlin.idea.util.requireNode +import org.jetbrains.kotlin.idea.util.* import org.jetbrains.kotlin.kdoc.lexer.KDocTokens import org.jetbrains.kotlin.kdoc.parser.KDocElementTypes import org.jetbrains.kotlin.lexer.KtTokens.* @@ -588,7 +585,7 @@ abstract class KotlinCommonBlock( when { elementType === VALUE_ARGUMENT_LIST -> { val wrapSetting = commonSettings.CALL_PARAMETERS_WRAP - if (!node.trailingCommaIsAllowed && + if (!node.addTrailingComma && (wrapSetting == CommonCodeStyleSettings.WRAP_AS_NEEDED || wrapSetting == CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM) && !needWrapArgumentList(nodePsi) ) { @@ -597,7 +594,7 @@ abstract class KotlinCommonBlock( return getWrappingStrategyForItemList( wrapSetting, VALUE_ARGUMENT, - node.trailingCommaIsAllowed, + node.addTrailingComma, additionalWrap = trailingCommaWrappingStrategyWithMultiLineCheck(LPAR, RPAR), ) } @@ -607,7 +604,7 @@ abstract class KotlinCommonBlock( FUN, PRIMARY_CONSTRUCTOR, SECONDARY_CONSTRUCTOR -> return getWrappingStrategyForItemList( commonSettings.METHOD_PARAMETERS_WRAP, VALUE_PARAMETER, - node.trailingCommaIsAllowed, + node.addTrailingComma, additionalWrap = trailingCommaWrappingStrategyWithMultiLineCheck(LPAR, RPAR), ) FUNCTION_TYPE -> return defaultTrailingCommaWrappingStrategy(LPAR, RPAR) @@ -752,8 +749,8 @@ abstract class KotlinCommonBlock( private fun defaultTrailingCommaWrappingStrategy(leftAnchor: IElementType, rightAnchor: IElementType): WrappingStrategy = fun(childElement: ASTNode): Wrap? = trailingCommaWrappingStrategyWithMultiLineCheck(leftAnchor, rightAnchor)(childElement) - private val ASTNode.trailingCommaIsAllowed: Boolean - get() = (settings.kotlinCustomSettings.ALLOW_TRAILING_COMMA || + private val ASTNode.addTrailingComma: Boolean + get() = (settings.kotlinCustomSettings.addTrailingCommaIsAllowedFor(this) || lastChildNode?.let { getSiblingWithoutWhitespaceAndComments(it) }?.elementType === COMMA) && psi?.let(PsiElement::isMultiline) == true @@ -821,7 +818,7 @@ abstract class KotlinCommonBlock( if (!filter(childElement)) return null val childElementType = childElement.elementType return createWrapAlwaysIf( - (!checkTrailingComma || childElement.treeParent.trailingCommaIsAllowed) && ( + (!checkTrailingComma || childElement.treeParent.addTrailingComma) && ( rightAnchor != null && rightAnchor === childElementType || leftAnchor != null && leftAnchor === getSiblingWithoutWhitespaceAndComments(childElement)?.elementType || additionalCheck(childElement) 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 49463ea177d..618a236795c 100644 --- a/idea/formatter/src/org/jetbrains/kotlin/idea/util/FormatterUtil.kt +++ b/idea/formatter/src/org/jetbrains/kotlin/idea/util/FormatterUtil.kt @@ -6,11 +6,17 @@ package org.jetbrains.kotlin.idea.util import com.intellij.formatting.ASTBlock +import com.intellij.lang.ASTNode import com.intellij.openapi.util.TextRange +import com.intellij.openapi.util.UserDataHolder +import com.intellij.openapi.util.registry.Registry import com.intellij.openapi.util.text.StringUtil import com.intellij.psi.PsiDocumentManager import com.intellij.psi.PsiElement import com.intellij.psi.codeStyle.CodeStyleSettings +import com.intellij.psi.tree.TokenSet +import com.intellij.psi.util.PsiUtilCore +import org.jetbrains.kotlin.KtNodeTypes import org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings import org.jetbrains.kotlin.idea.formatter.kotlinCustomSettings import org.jetbrains.kotlin.psi.KtDestructuringDeclaration @@ -77,7 +83,9 @@ fun T.needTrailingComma( globalStartOffset: T.() -> Int? = PsiElement::startOffset, globalEndOffset: T.() -> Int? = PsiElement::endOffset, ): Boolean { - if (trailingComma() == null && !settings.kotlinCustomSettings.ALLOW_TRAILING_COMMA || !additionalCheck()) return false + if (trailingComma() == null && !settings.kotlinCustomSettings.addTrailingCommaIsAllowedFor(this)) return false + if (!additionalCheck()) return false + val startOffset = globalStartOffset() ?: return false val endOffset = globalEndOffset() ?: return false return containsLineBreakInThis(startOffset, endOffset) @@ -86,4 +94,35 @@ fun T.needTrailingComma( fun PsiElement.containsLineBreakInThis(globalStartOffset: Int, globalEndOffset: Int): Boolean { val textRange = TextRange.create(globalStartOffset, globalEndOffset).shiftLeft(startOffset) return StringUtil.containsLineBreak(textRange.subSequence(text)) -} \ No newline at end of file +} + +fun trailingCommaIsAllowedOnCallSite(): Boolean = Registry.`is`("kotlin.formatter.allowTrailingCommaOnCallSite") + +private val TYPES_WITH_TRAILING_COMMA = TokenSet.create( + KtNodeTypes.TYPE_PARAMETER_LIST, + KtNodeTypes.DESTRUCTURING_DECLARATION, + KtNodeTypes.WHEN_ENTRY, + KtNodeTypes.FUNCTION_LITERAL, + KtNodeTypes.VALUE_PARAMETER_LIST, +) + +private val TYPES_WITH_TRAILING_COMMA_ON_CALL_SITE = TokenSet.create( + KtNodeTypes.COLLECTION_LITERAL_EXPRESSION, + KtNodeTypes.TYPE_ARGUMENT_LIST, + KtNodeTypes.INDICES, + KtNodeTypes.VALUE_ARGUMENT_LIST, +) + +fun UserDataHolder.addTrailingCommaIsAllowedForThis(): Boolean { + val type = when (this) { + is ASTNode -> PsiUtilCore.getElementType(this) + is PsiElement -> PsiUtilCore.getElementType(this) + else -> return false + } + + return type in TYPES_WITH_TRAILING_COMMA || trailingCommaIsAllowedOnCallSite() && type in TYPES_WITH_TRAILING_COMMA_ON_CALL_SITE +} + +fun KotlinCodeStyleSettings.addTrailingCommaIsAllowedFor(element: UserDataHolder): Boolean = + ALLOW_TRAILING_COMMA && element.addTrailingCommaIsAllowedForThis() + diff --git a/idea/resources/META-INF/extensions/ide.xml b/idea/resources/META-INF/extensions/ide.xml index e153a6b4c35..08eecd58c6a 100644 --- a/idea/resources/META-INF/extensions/ide.xml +++ b/idea/resources/META-INF/extensions/ide.xml @@ -127,6 +127,10 @@ description="Allow a trailing comma regardless of plugin version" defaultValue="false" restartRequired="false"/> + diff --git a/idea/src/org/jetbrains/kotlin/idea/formatter/TrailingCommaPostFormatProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/formatter/TrailingCommaPostFormatProcessor.kt index bcfb8132cf1..a705bd571a8 100644 --- a/idea/src/org/jetbrains/kotlin/idea/formatter/TrailingCommaPostFormatProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/formatter/TrailingCommaPostFormatProcessor.kt @@ -23,10 +23,7 @@ import org.jetbrains.kotlin.idea.formatter.TrailingCommaPostFormatProcessor.Comp import org.jetbrains.kotlin.idea.formatter.TrailingCommaPostFormatProcessor.Companion.trailingCommaAllowedInModule import org.jetbrains.kotlin.idea.formatter.TrailingCommaPostFormatProcessor.Companion.trailingCommaOrLastElement import org.jetbrains.kotlin.idea.project.languageVersionSettings -import org.jetbrains.kotlin.idea.util.isLineBreak -import org.jetbrains.kotlin.idea.util.isMultiline -import org.jetbrains.kotlin.idea.util.module -import org.jetbrains.kotlin.idea.util.needTrailingComma +import org.jetbrains.kotlin.idea.util.* import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.* @@ -63,7 +60,8 @@ class TrailingCommaPostFormatProcessor : PostFormatProcessor { else -> (checkExistingTrailingComma && trailingCommaOrLastElement(commaOwner)?.isComma == true || - settings.kotlinCustomSettings.ALLOW_TRAILING_COMMA) && commaOwner.isMultiline() + settings.kotlinCustomSettings.addTrailingCommaIsAllowedFor(commaOwner)) && + commaOwner.isMultiline() } fun trailingCommaOrLastElement(commaOwner: KtElement): PsiElement? { diff --git a/idea/src/org/jetbrains/kotlin/idea/formatter/TrailingCommaVisitor.kt b/idea/src/org/jetbrains/kotlin/idea/formatter/TrailingCommaVisitor.kt index 34cb42e2e04..4ae3b883949 100644 --- a/idea/src/org/jetbrains/kotlin/idea/formatter/TrailingCommaVisitor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/formatter/TrailingCommaVisitor.kt @@ -7,47 +7,48 @@ package org.jetbrains.kotlin.idea.formatter import com.intellij.openapi.progress.ProgressIndicatorProvider import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.idea.util.addTrailingCommaIsAllowedForThis import org.jetbrains.kotlin.psi.* abstract class TrailingCommaVisitor : KtTreeVisitorVoid() { override fun visitParameterList(list: KtParameterList) { super.visitParameterList(list) - process(list) + runProcessIfAllowed(list) } override fun visitValueArgumentList(list: KtValueArgumentList) { super.visitValueArgumentList(list) - process(list) + runProcessIfAllowed(list) } override fun visitArrayAccessExpression(expression: KtArrayAccessExpression) { super.visitArrayAccessExpression(expression) - process(expression.indicesNode) + runProcessIfAllowed(expression.indicesNode) } override fun visitTypeParameterList(list: KtTypeParameterList) { super.visitTypeParameterList(list) - process(list) + runProcessIfAllowed(list) } override fun visitTypeArgumentList(typeArgumentList: KtTypeArgumentList) { super.visitTypeArgumentList(typeArgumentList) - process(typeArgumentList) + runProcessIfAllowed(typeArgumentList) } override fun visitCollectionLiteralExpression(expression: KtCollectionLiteralExpression) { super.visitCollectionLiteralExpression(expression) - process(expression) + runProcessIfAllowed(expression) } override fun visitWhenEntry(jetWhenEntry: KtWhenEntry) { super.visitWhenEntry(jetWhenEntry) - process(jetWhenEntry) + runProcessIfAllowed(jetWhenEntry) } override fun visitDestructuringDeclaration(destructuringDeclaration: KtDestructuringDeclaration) { super.visitDestructuringDeclaration(destructuringDeclaration) - process(destructuringDeclaration) + runProcessIfAllowed(destructuringDeclaration) } override fun visitElement(element: PsiElement) { @@ -56,6 +57,12 @@ abstract class TrailingCommaVisitor : KtTreeVisitorVoid() { if (recursively) super.visitElement(element) } + private fun runProcessIfAllowed(element: KtElement) { + if (element.addTrailingCommaIsAllowedForThis()) { + process(element) + } + } + protected abstract fun process(commaOwner: KtElement) protected open val recursively: Boolean = true diff --git a/idea/testData/formatter/callChain/CallChainWrapping.after.kt b/idea/testData/formatter/callChain/CallChainWrapping.after.kt index 72aee707411..98f99ffe12c 100644 --- a/idea/testData/formatter/callChain/CallChainWrapping.after.kt +++ b/idea/testData/formatter/callChain/CallChainWrapping.after.kt @@ -30,11 +30,9 @@ val x8 = foo!!!!!!!!.bar() val x9 = ((b!!)!!!!)!!.f -val y = xyzzy( - foo.bar() - .baz() - .quux(), -) +val y = xyzzy(foo.bar() + .baz() + .quux()) fun foo() { foo.bar() diff --git a/idea/testData/formatter/callChain/FunctionLiteralsInChainCalls.after.kt b/idea/testData/formatter/callChain/FunctionLiteralsInChainCalls.after.kt index bf2018018d5..f8c9ca2289e 100644 --- a/idea/testData/formatter/callChain/FunctionLiteralsInChainCalls.after.kt +++ b/idea/testData/formatter/callChain/FunctionLiteralsInChainCalls.after.kt @@ -12,16 +12,12 @@ fun test() { fun test1() { val abc = ArrayList() - .map( - { - it * 2 - }, - ) - .filter( - { - it > 4 - }, - ) + .map({ + it * 2 + }) + .filter({ + it > 4 + }) } fun test2() { @@ -39,7 +35,7 @@ fun test3() { fun test4() { val abc = ArrayList().mapTo( - LinkedHashSet(), + LinkedHashSet() ) { it * 2 } diff --git a/idea/testData/formatter/trailingComma/collectionLiteralExpression/CollectionLiteralInAnnotation.after.inv.kt b/idea/testData/formatter/trailingComma/collectionLiteralExpression/CollectionLiteralInAnnotation.after.inv.kt index 3eeca972c74..81244145895 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 bd5a487efb4..81244145895 100644 --- a/idea/testData/formatter/trailingComma/collectionLiteralExpression/CollectionLiteralInAnnotation.after.kt +++ b/idea/testData/formatter/trailingComma/collectionLiteralExpression/CollectionLiteralInAnnotation.after.kt @@ -3,182 +3,123 @@ @Anno([1]) fun a() = Unit -@Anno([1]) +@Anno([1, ]) fun a() = Unit -@Anno( - [ - 1, - ], -) +@Anno([1 +]) fun a() = Unit -@Anno( - [ - 1, - ], -) +@Anno([ + 1, +]) fun a() = Unit -@Anno( - [ - 1, - ], -) +@Anno([ + 1]) fun a() = Unit @Anno([1, 2]) fun a() = Unit -@Anno([1, 2]) +@Anno([1, 2, ]) fun a() = Unit -@Anno( - [ - 1, 2, - ], -) +@Anno([1, 2 +]) fun a() = Unit -@Anno( - [ - 1, 2, - ], -) +@Anno([ + 1, 2, +]) fun a() = Unit -@Anno( - [ - 1, 2, - ], -) +@Anno([ + 1, 2]) fun a() = Unit @Anno([1, 2, 2]) fun a() = Unit -@Anno([1, 2, 2]) +@Anno([1, 2, 2, ]) fun a() = Unit -@Anno( - [ - "1", - ], -) +@Anno(["1" +]) fun a() = Unit -@Anno( - [ - 1, - ], -) +@Anno([ + 1, +]) fun a() = Unit -@Anno( - [ - 1, 2, 2, - ], -) +@Anno([ + 1, 2, 2]) fun a() = Unit -@Anno( - [ - 1,/* - */ - ], -) +@Anno([1/* + */]) fun a() = Unit -@Anno( - [ - 1, //dw - ], -) +@Anno([ + 1, //dw +]) fun a() = Unit -@Anno( - [ - 1, // ds - ], -) +@Anno([1 // ds +]) fun a() = Unit -@Anno( - [ +@Anno([ /* */ - // d - 1,/* - *//* + // d + 1/* + */,/* */ - ], -) +]) fun a() = Unit -@Anno( - [ - /* - */ - 1, - ], -) +@Anno([ + /* +*/ 1]) fun a() = Unit -@Anno( - [ - 1,/* +@Anno([1/* + */, 2]) +fun a() = Unit + +@Anno([ + 1, + 2/* + */,/* */ - 2, - ], -) +]) fun a() = Unit -@Anno( - [ - 1, - 2,/* - *//* - */ - ], -) +@Anno([/* + */1, 2 +]) fun a() = Unit -@Anno( - [ -/* - */ - 1, 2, - ], -) +@Anno(["1" +]) fun a() = Unit -@Anno( - [ - "1", - ], -) +@Anno([ + 1, +]) fun a() = Unit -@Anno( - [ - 1, - ], -) -fun a() = Unit - -@Anno( - [ - 1, - 2, /* - */ - ], -) +@Anno([ + 1, 2 /* + */]) fun a() = Unit @Component( modules = [ AppModule::class, DataModule::class, - DomainModule::class, + DomainModule::class ], ) fun b() = Unit \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/collectionLiteralExpression/CollectionLiteralInAnnotation.call.after.inv.kt b/idea/testData/formatter/trailingComma/collectionLiteralExpression/CollectionLiteralInAnnotation.call.after.inv.kt new file mode 100644 index 00000000000..3eeca972c74 --- /dev/null +++ b/idea/testData/formatter/trailingComma/collectionLiteralExpression/CollectionLiteralInAnnotation.call.after.inv.kt @@ -0,0 +1,125 @@ +// SET_TRUE: ALLOW_TRAILING_COMMA + +@Anno([1]) +fun a() = Unit + +@Anno([1]) +fun a() = Unit + +@Anno([1 +]) +fun a() = Unit + +@Anno([ + 1, +]) +fun a() = Unit + +@Anno([ + 1]) +fun a() = Unit + +@Anno([1, 2]) +fun a() = Unit + +@Anno([1, 2]) +fun a() = Unit + +@Anno([1, 2 +]) +fun a() = Unit + +@Anno([ + 1, 2, +]) +fun a() = Unit + +@Anno([ + 1, 2]) +fun a() = Unit + +@Anno([1, 2, 2]) +fun a() = Unit + +@Anno([1, 2, 2]) +fun a() = Unit + +@Anno(["1" +]) +fun a() = Unit + +@Anno([ + 1, +]) +fun a() = Unit + +@Anno([ + 1, 2, 2]) +fun a() = Unit + +@Anno([1/* + */]) +fun a() = Unit + +@Anno([ + 1, //dw +]) +fun a() = Unit + +@Anno([1 // ds +]) +fun a() = Unit + +@Anno([ +/* + */ + // d + 1,/* + *//* + */ +]) +fun a() = Unit + +@Anno([ + /* +*/ 1]) +fun a() = Unit + +@Anno([1/* + */, 2]) +fun a() = Unit + +@Anno([ + 1, + 2,/* + *//* + */ +]) +fun a() = Unit + +@Anno([/* + */1, 2 +]) +fun a() = Unit + +@Anno(["1" +]) +fun a() = Unit + +@Anno([ + 1, +]) +fun a() = Unit + +@Anno([ + 1, 2 /* + */]) +fun a() = Unit + +@Component( + modules = [ + AppModule::class, DataModule::class, + DomainModule::class + ], +) +fun b() = Unit \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/collectionLiteralExpression/CollectionLiteralInAnnotation.call.after.kt b/idea/testData/formatter/trailingComma/collectionLiteralExpression/CollectionLiteralInAnnotation.call.after.kt new file mode 100644 index 00000000000..bd5a487efb4 --- /dev/null +++ b/idea/testData/formatter/trailingComma/collectionLiteralExpression/CollectionLiteralInAnnotation.call.after.kt @@ -0,0 +1,184 @@ +// SET_TRUE: ALLOW_TRAILING_COMMA + +@Anno([1]) +fun a() = Unit + +@Anno([1]) +fun a() = Unit + +@Anno( + [ + 1, + ], +) +fun a() = Unit + +@Anno( + [ + 1, + ], +) +fun a() = Unit + +@Anno( + [ + 1, + ], +) +fun a() = Unit + +@Anno([1, 2]) +fun a() = Unit + +@Anno([1, 2]) +fun a() = Unit + +@Anno( + [ + 1, 2, + ], +) +fun a() = Unit + +@Anno( + [ + 1, 2, + ], +) +fun a() = Unit + +@Anno( + [ + 1, 2, + ], +) +fun a() = Unit + +@Anno([1, 2, 2]) +fun a() = Unit + +@Anno([1, 2, 2]) +fun a() = Unit + +@Anno( + [ + "1", + ], +) +fun a() = Unit + +@Anno( + [ + 1, + ], +) +fun a() = Unit + +@Anno( + [ + 1, 2, 2, + ], +) +fun a() = Unit + +@Anno( + [ + 1,/* + */ + ], +) +fun a() = Unit + +@Anno( + [ + 1, //dw + ], +) +fun a() = Unit + +@Anno( + [ + 1, // ds + ], +) +fun a() = Unit + +@Anno( + [ +/* + */ + // d + 1,/* + *//* + */ + ], +) +fun a() = Unit + +@Anno( + [ + /* + */ + 1, + ], +) +fun a() = Unit + +@Anno( + [ + 1,/* + */ + 2, + ], +) +fun a() = Unit + +@Anno( + [ + 1, + 2,/* + *//* + */ + ], +) +fun a() = Unit + +@Anno( + [ +/* + */ + 1, 2, + ], +) +fun a() = Unit + +@Anno( + [ + "1", + ], +) +fun a() = Unit + +@Anno( + [ + 1, + ], +) +fun a() = Unit + +@Anno( + [ + 1, + 2, /* + */ + ], +) +fun a() = Unit + +@Component( + modules = [ + AppModule::class, DataModule::class, + DomainModule::class, + ], +) +fun b() = Unit \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/enumEntry/Enum.after.kt b/idea/testData/formatter/trailingComma/enumEntry/Enum.after.kt index 957012fff3e..6d80aa1b832 100644 --- a/idea/testData/formatter/trailingComma/enumEntry/Enum.after.kt +++ b/idea/testData/formatter/trailingComma/enumEntry/Enum.after.kt @@ -24,14 +24,14 @@ enum class Enum5 { enum class Enum6(val a: Int) { A( - 1, + 1 ), B, } enum class Enum7(val a: Int) { A( - 1, + 1 ), B, ; @@ -39,7 +39,7 @@ enum class Enum7(val a: Int) { enum class Enum8(val a: Int) { A( - 1, + 1 ), B; } \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/indices/IndicesAccess.after.inv.kt b/idea/testData/formatter/trailingComma/indices/IndicesAccess.after.inv.kt index ee6fad75cbf..83ec56e7bc4 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,13 +112,11 @@ 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() { @@ -173,7 +171,7 @@ fun foo() { foofoo ] - testtest[foofoo/**/] + testtest[foofoo,/**/] testtest[foofoo, foofoo, foofoo, foofoo/* */, /* */ bar @@ -186,7 +184,7 @@ fun foo() { foofoo ] - testtest[foofoo/**/] + testtest[foofoo,/**/] testtest[ foofoo, fososos,/* @@ -194,16 +192,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 2844cebc48c..83ec56e7bc4 100644 --- a/idea/testData/formatter/trailingComma/indices/IndicesAccess.after.kt +++ b/idea/testData/formatter/trailingComma/indices/IndicesAccess.after.kt @@ -1,37 +1,31 @@ // SET_TRUE: ALLOW_TRAILING_COMMA fun foo() { + testtest[foofoo, foofoo, foofoo, + foofoo, bar] + testtest[ - foofoo, foofoo, foofoo, - foofoo, bar, + foofoo, foofoo, foofoo, foofoo, bar + ] + + testtest[foofoo, foofoo, foofoo, foofoo, bar + ] + + testtest[foofoo, foofoo, foofoo, foofoo, + bar + ] + + testtest[foofoo ] testtest[ - foofoo, foofoo, foofoo, foofoo, bar, - ] + foofoo] testtest[ - foofoo, foofoo, foofoo, foofoo, bar, + foofoo ] - testtest[ - foofoo, foofoo, foofoo, foofoo, - bar, - ] - - testtest[ - foofoo, - ] - - testtest[ - foofoo, - ] - - testtest[ - foofoo, - ] - - testtest[foofoo] + testtest[foofoo, ] testtest[foofoo, testtest[testtest[foofoo]]] @@ -40,25 +34,21 @@ 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"] }] - useCallable[ - "B", "C", - Callable { - println["Hello world"] - }, - Callable { - println["Hello world"] - }, - ] + useCallable["B", "C", Callable { + println["Hello world"] + }, Callable { + println["Hello world"] + }] useCallable[Callable { println["Hello world"] }] - useCallable[Callable { println["Hello world"] }] + useCallable[Callable { println["Hello world"] }, ] useCallable[ Callable { @@ -66,8 +56,7 @@ fun foo() { }, ] - useCallable[ - Callable { println["Hello world"] }, + useCallable[Callable { println["Hello world"] } ] useCallable[Callable { println["Hello world"] }]{ @@ -75,96 +64,72 @@ fun foo() { } useCallable[ - Callable { println["Hello world"] }, - ] + Callable { println["Hello world"] }] useCallable["A", { println["Hello world"] }] - useCallable[ - "B", "C", - { - println["Hello world"] - }, - { - println["Hello world"] - }, - ] + useCallable["B", "C", { + println["Hello world"] + }, { + println["Hello world"] + }] useCallable[{ println["Hello world"] }] - useCallable[{ println["Hello world"] }] + useCallable[{ println["Hello world"] }, ] useCallable[ { println["Hello world"] }, ] - useCallable[ - { println["Hello world"] }, + useCallable[{ println["Hello world"] } ] useCallable[ - { println["Hello world"] }, + { println["Hello world"] }] + + useCallable["A", object : Callable { + override fun call() { + println["Hello world"] + } + }] + + useCallable["A", object : Callable { + override fun call() { + println["Hello world"] + } + }] + + useCallable["B", "C", object : Callable { + override fun call() { + println["Hello world"] + } + }, foo[0, ]] + + useCallable[object : Callable { + override fun call() { + println["Hello world"] + } + }] + + useCallable[object : Callable { + override fun call() { + println["Hello world"] + } + }, ] + + useCallable[object : Callable { + override fun call() { + println["Hello world"] + } + } ] - useCallable[ - "A", - object : Callable { - override fun call() { - println["Hello world"] - } - }, - ] - - useCallable[ - "A", - object : Callable { - override fun call() { - println["Hello world"] - } - }, - ] - - useCallable[ - "B", "C", - object : Callable { - override fun call() { - println["Hello world"] - } - }, - foo[0], - ] - - useCallable[ - object : Callable { - override fun call() { - println["Hello world"] - } - }, - ] - - useCallable[ - object : Callable { - override fun call() { - println["Hello world"] - } - }, - ] - - useCallable[ - object : Callable { - override fun call() { - println["Hello world"] - } - }, - ] - - useCallable[ - object : Callable { - override fun call() { - println["Hello world"] - } - }, - ] { + useCallable[object : Callable { + override fun call() { + println["Hello world"] + } + }] { } @@ -173,70 +138,53 @@ fun foo() { override fun call() { println["Hello world"] } - }, - ] + }] testtest[ foofoo, foofoo, foofoo, foofoo, - bar, /* - */ /* */ - foo, + bar /* + */, /* */ foo ] - testtest[ -/* - */ - foofoo, foofoo, foofoo, /* + testtest[/* + */foofoo, foofoo, foofoo, /* */ - foofoo, bar, + foofoo, bar] + + testtest[foofoo, foofoo, foofoo, foofoo, bar/* + */] + + testtest[foofoo, foofoo, foofoo, foofoo, bar // awdawda ] - testtest[ - foofoo, foofoo, foofoo, foofoo, - bar,/* - */ - ] - - testtest[ - foofoo, foofoo, foofoo, foofoo, bar, // awdawda - ] - - testtest[ - foofoo, foofoo, foofoo, foofoo, /* + testtest[foofoo, foofoo, foofoo, foofoo, /* */ - bar, + bar ] - testtest[ - foofoo, // fd + testtest[foofoo // fd ] - testtest[ - /**/ - foofoo, + testtest[ /**/ + foofoo ] - testtest[foofoo/**/] + testtest[foofoo,/**/] - testtest[ - foofoo, foofoo, foofoo, - foofoo,/* - */ /* */ - bar, + testtest[foofoo, foofoo, foofoo, foofoo/* + */, /* */ bar ] - testtest[ - foofoo, // fd + testtest[foofoo // fd ] - testtest[ - /**/ - foofoo, + testtest[ /**/ + foofoo ] - testtest[foofoo/**/] + testtest[foofoo,/**/] testtest[ foofoo, fososos,/* @@ -244,36 +192,24 @@ 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"] - }, /* */ - Callable { - println["Hello world"] - }, - ] + useCallable["B", "C", Callable { + println["Hello world"] + }, /* */ Callable { + println["Hello world"] + }] - useCallable[ - Callable { println["Hello world"] }, // ffd + useCallable[Callable { println["Hello world"] } // ffd ] } \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/indices/IndicesAccess.call.after.inv.kt b/idea/testData/formatter/trailingComma/indices/IndicesAccess.call.after.inv.kt new file mode 100644 index 00000000000..ee6fad75cbf --- /dev/null +++ b/idea/testData/formatter/trailingComma/indices/IndicesAccess.call.after.inv.kt @@ -0,0 +1,217 @@ +// SET_TRUE: ALLOW_TRAILING_COMMA + +fun foo() { + testtest[foofoo, foofoo, foofoo, + foofoo, bar] + + testtest[ + foofoo, foofoo, foofoo, foofoo, bar + ] + + testtest[foofoo, foofoo, foofoo, foofoo, bar + ] + + testtest[foofoo, foofoo, foofoo, foofoo, + bar + ] + + testtest[foofoo + ] + + testtest[ + foofoo] + + testtest[ + foofoo + ] + + testtest[foofoo] + + testtest[foofoo, testtest[testtest[foofoo]]] + + testtest[ + foofoo, fososos, + testtest[testtest[foofoo]], + ] + + testtest[foofoo, testtest[testtest[foofoo]], testsa] + + testtest[foofoo, seee, testtest[testtest[foofoo]], testsa] + + useCallable["A", Callable { println["Hello world"] }] + + useCallable["B", "C", Callable { + println["Hello world"] + }, Callable { + println["Hello world"] + }] + + useCallable[Callable { println["Hello world"] }] + + useCallable[Callable { println["Hello world"] }] + + useCallable[ + Callable { + println["Hello world"] + }, + ] + + useCallable[Callable { println["Hello world"] } + ] + + useCallable[Callable { println["Hello world"] }]{ + + } + + useCallable[ + Callable { println["Hello world"] }] + + useCallable["A", { println["Hello world"] }] + + useCallable["B", "C", { + println["Hello world"] + }, { + println["Hello world"] + }] + + useCallable[{ println["Hello world"] }] + + useCallable[{ println["Hello world"] }] + + useCallable[ + { println["Hello world"] }, + ] + + useCallable[{ println["Hello world"] } + ] + + useCallable[ + { println["Hello world"] }] + + useCallable["A", object : Callable { + override fun call() { + println["Hello world"] + } + }] + + useCallable["A", object : Callable { + override fun call() { + println["Hello world"] + } + }] + + useCallable["B", "C", object : Callable { + override fun call() { + println["Hello world"] + } + }, foo[0]] + + useCallable[object : Callable { + override fun call() { + println["Hello world"] + } + }] + + useCallable[ + object : Callable { + override fun call() { + println["Hello world"] + } + }, + ] + + useCallable[object : Callable { + override fun call() { + println["Hello world"] + } + } + ] + + useCallable[object : Callable { + override fun call() { + println["Hello world"] + } + }] { + + } + + useCallable[ + object : Callable { + override fun call() { + println["Hello world"] + } + }] + + testtest[ + foofoo, foofoo, foofoo, foofoo, + bar /* + */, /* */ foo + ] + + testtest[/* + */foofoo, foofoo, foofoo, /* + + */ + foofoo, bar] + + testtest[foofoo, foofoo, foofoo, foofoo, bar/* + */] + + testtest[foofoo, foofoo, foofoo, foofoo, bar // awdawda + ] + + testtest[foofoo, foofoo, foofoo, foofoo, /* + + */ + bar + ] + + testtest[foofoo // fd + ] + + testtest[ /**/ + foofoo + ] + + testtest[foofoo/**/] + + testtest[foofoo, foofoo, foofoo, foofoo/* + */, /* */ bar + ] + + testtest[foofoo // fd + ] + + testtest[ /**/ + foofoo + ] + + testtest[foofoo/**/] + + testtest[ + foofoo, fososos,/* + */ + testtest[testtest[foofoo]], + ] + + 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] + + useCallable["B", "C", Callable { + println["Hello world"] + }, /* */ Callable { + println["Hello world"] + }] + + useCallable[Callable { println["Hello world"] } // ffd + ] +} \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/indices/IndicesAccess.call.after.kt b/idea/testData/formatter/trailingComma/indices/IndicesAccess.call.after.kt new file mode 100644 index 00000000000..2844cebc48c --- /dev/null +++ b/idea/testData/formatter/trailingComma/indices/IndicesAccess.call.after.kt @@ -0,0 +1,279 @@ +// SET_TRUE: ALLOW_TRAILING_COMMA + +fun foo() { + testtest[ + foofoo, foofoo, foofoo, + foofoo, bar, + ] + + testtest[ + foofoo, foofoo, foofoo, foofoo, bar, + ] + + testtest[ + foofoo, foofoo, foofoo, foofoo, bar, + ] + + testtest[ + foofoo, foofoo, foofoo, foofoo, + bar, + ] + + testtest[ + foofoo, + ] + + testtest[ + foofoo, + ] + + testtest[ + foofoo, + ] + + testtest[foofoo] + + testtest[foofoo, testtest[testtest[foofoo]]] + + testtest[ + foofoo, fososos, + testtest[testtest[foofoo]], + ] + + testtest[foofoo, testtest[testtest[foofoo]], testsa] + + testtest[foofoo, seee, testtest[testtest[foofoo]], testsa] + + useCallable["A", Callable { println["Hello world"] }] + + useCallable[ + "B", "C", + Callable { + println["Hello world"] + }, + Callable { + println["Hello world"] + }, + ] + + useCallable[Callable { println["Hello world"] }] + + useCallable[Callable { println["Hello world"] }] + + useCallable[ + Callable { + println["Hello world"] + }, + ] + + useCallable[ + Callable { println["Hello world"] }, + ] + + useCallable[Callable { println["Hello world"] }]{ + + } + + useCallable[ + Callable { println["Hello world"] }, + ] + + useCallable["A", { println["Hello world"] }] + + useCallable[ + "B", "C", + { + println["Hello world"] + }, + { + println["Hello world"] + }, + ] + + useCallable[{ println["Hello world"] }] + + useCallable[{ println["Hello world"] }] + + useCallable[ + { println["Hello world"] }, + ] + + useCallable[ + { println["Hello world"] }, + ] + + useCallable[ + { println["Hello world"] }, + ] + + useCallable[ + "A", + object : Callable { + override fun call() { + println["Hello world"] + } + }, + ] + + useCallable[ + "A", + object : Callable { + override fun call() { + println["Hello world"] + } + }, + ] + + useCallable[ + "B", "C", + object : Callable { + override fun call() { + println["Hello world"] + } + }, + foo[0], + ] + + useCallable[ + object : Callable { + override fun call() { + println["Hello world"] + } + }, + ] + + useCallable[ + object : Callable { + override fun call() { + println["Hello world"] + } + }, + ] + + useCallable[ + object : Callable { + override fun call() { + println["Hello world"] + } + }, + ] + + useCallable[ + object : Callable { + override fun call() { + println["Hello world"] + } + }, + ] { + + } + + useCallable[ + object : Callable { + override fun call() { + println["Hello world"] + } + }, + ] + + testtest[ + foofoo, foofoo, foofoo, foofoo, + bar, /* + */ /* */ + foo, + ] + + testtest[ +/* + */ + foofoo, foofoo, foofoo, /* + + */ + foofoo, bar, + ] + + testtest[ + foofoo, foofoo, foofoo, foofoo, + bar,/* + */ + ] + + testtest[ + foofoo, foofoo, foofoo, foofoo, bar, // awdawda + ] + + testtest[ + foofoo, foofoo, foofoo, foofoo, /* + + */ + bar, + ] + + testtest[ + foofoo, // fd + ] + + testtest[ + /**/ + foofoo, + ] + + testtest[foofoo/**/] + + testtest[ + foofoo, foofoo, foofoo, + foofoo,/* + */ /* */ + bar, + ] + + testtest[ + foofoo, // fd + ] + + testtest[ + /**/ + foofoo, + ] + + testtest[foofoo/**/] + + testtest[ + foofoo, fososos,/* + */ + testtest[testtest[foofoo]], + ] + + 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, + ] + + useCallable[ + "B", "C", + Callable { + println["Hello world"] + }, /* */ + Callable { + println["Hello world"] + }, + ] + + useCallable[ + Callable { println["Hello world"] }, // ffd + ] +} \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/lambdaParameters/LambdaParameterList.call.after.inv.kt b/idea/testData/formatter/trailingComma/lambdaParameters/LambdaParameterList.call.after.inv.kt new file mode 100644 index 00000000000..55175344225 --- /dev/null +++ b/idea/testData/formatter/trailingComma/lambdaParameters/LambdaParameterList.call.after.inv.kt @@ -0,0 +1,188 @@ +val x = { + x: Comparable>, + y: String, + -> + println("1") +} + +val x = { x: Comparable>, y: String -> + println("1") +} + +val x = { x: String, y +: String -> + println("1") +} + +val x = { x: String, + y: String + -> + println("1") +} + +val x = { + x: String, + y: Comparable>, + -> + println("1") +} + +val x = { + x: Comparable>, + y: String, + -> + println("1") +} + +val x = { + x: String, + y: Comparable>, + z: String, + -> + println("1") +} + +val x = { x: String, + y: String, + z: String + -> + println("1") +} + +val x = { + x: String, + y: String, + z: String, + -> + println("1") +} + +val x = { + x: String, + y: String, + z: String, + -> + println("1") +} + +val x = { + x: String, + -> + println("1") +} + +val x = { x: String + -> + println("1") +} + +val x = { x: String -> + println("1") +} + +val x = { + x: String, + -> + println("1") +} + +val x = { + x: String, + y: String, + -> + println("1") +} + +val x = { x: String, + z: String + -> + println("1") +} + +val x = { + x: String, + y: String, + z: String, + -> + println("1") +} + +val x = { + x: String, + z: String, + -> + println("1") +} + +val x = { + x, y: String, + z: String, + -> + println("1") +} + +val x = { x: String, y: String, z: String + -> + println("1") +} + +val x = { + z: String, v: Comparable>, + + -> + println("1") +} + +val x = { + x: String, + y: Comparable>, + -> + println("1") +} + +val x = { x: Int + -> + println("1") +} + +val x = { x: String, y: String, /* */ z: String + -> + println("1") +} + +val x = { x: String, y: String + /* */, /* */ z: String + -> + println("1") +}() + +val x = { + x: String, /* + */ + y: String, + z: String, + -> + println("1") +} + +val x = { + x: String, y: String, + z: String, /* + */ + -> + println("1") +} + +val x = { + x: Comparable>, y: String, + z: String, + -> + println("1") +} + +val x = { x: String, y: String, z: String + -> + println("1") +} + +// SET_TRUE: ALLOW_TRAILING_COMMA diff --git a/idea/testData/formatter/trailingComma/lambdaParameters/LambdaParameterList.call.after.kt b/idea/testData/formatter/trailingComma/lambdaParameters/LambdaParameterList.call.after.kt new file mode 100644 index 00000000000..cfc30823c94 --- /dev/null +++ b/idea/testData/formatter/trailingComma/lambdaParameters/LambdaParameterList.call.after.kt @@ -0,0 +1,203 @@ +val x = { + x: Comparable>, + y: String, + -> + println("1") +} + +val x = { x: Comparable>, y: String -> + println("1") +} + +val x = { + x: String, + y + : String, + -> + println("1") +} + +val x = { + x: String, + y: String, + -> + println("1") +} + +val x = { + x: String, + y: Comparable>, + -> + println("1") +} + +val x = { + x: Comparable>, + y: String, + -> + println("1") +} + +val x = { + x: String, + y: Comparable>, + z: String, + -> + println("1") +} + +val x = { + x: String, + y: String, + z: String, + -> + println("1") +} + +val x = { + x: String, + y: String, + z: String, + -> + println("1") +} + +val x = { + x: String, + y: String, + z: String, + -> + println("1") +} + +val x = { + x: String, + -> + println("1") +} + +val x = { + x: String, + -> + println("1") +} + +val x = { x: String -> + println("1") +} + +val x = { + x: String, + -> + println("1") +} + +val x = { + x: String, + y: String, + -> + println("1") +} + +val x = { + x: String, + z: String, + -> + println("1") +} + +val x = { + x: String, + y: String, + z: String, + -> + println("1") +} + +val x = { + x: String, + z: String, + -> + println("1") +} + +val x = { + x, y: String, + z: String, + -> + println("1") +} + +val x = { + x: String, y: String, z: String, + -> + println("1") +} + +val x = { + z: String, v: Comparable>, + + -> + println("1") +} + +val x = { + x: String, + y: Comparable>, + -> + println("1") +} + +val x = { + x: Int, + -> + println("1") +} + +val x = { + x: String, y: String, /* */ + z: String, + -> + println("1") +} + +val x = { + x: String, + y: String, + /* */ /* */ + z: String, + -> + println("1") +}() + +val x = { + x: String, /* + */ + y: String, + z: String, + -> + println("1") +} + +val x = { + x: String, y: String, + z: String, /* + */ + -> + println("1") +} + +val x = { + x: Comparable>, y: String, + z: String, + -> + println("1") +} + +val x = { + x: String, y: String, z: String, + -> + println("1") +} + +// SET_TRUE: ALLOW_TRAILING_COMMA diff --git a/idea/testData/formatter/trailingComma/typeArguments/TypeArgumentList.after.inv.kt b/idea/testData/formatter/trailingComma/typeArguments/TypeArgumentList.after.inv.kt index 4345cac8a65..1a08abdc454 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 8f5452676a7..1a08abdc454 100644 --- a/idea/testData/formatter/trailingComma/typeArguments/TypeArgumentList.after.kt +++ b/idea/testData/formatter/trailingComma/typeArguments/TypeArgumentList.after.kt @@ -11,111 +11,89 @@ fun foo() { testsa, >() + testtest() + testtest< - foofoo, foofoo, foofoo, - foofoo, bar, + foofoo, foofoo, foofoo, foofoo, bar + >() + + testtest() + + testtest() + + testtest() testtest< - foofoo, foofoo, foofoo, foofoo, bar, - >() + foofoo>() testtest< - foofoo, foofoo, foofoo, foofoo, bar, + foofoo >() - testtest< - foofoo, foofoo, foofoo, foofoo, - bar, - >() - - testtest< - foofoo, - >() - - testtest< - foofoo, - >() - - testtest< - foofoo, - >() - - testtest() + testtest() testtest>>() - testtest>>() + testtest>, >() testtest< foofoo, fososos, testtest>, >() - testtest>, testsa>() + testtest>, testsa>() - testtest>, testsa>() + testtest>, testsa>() testtest< foofoo, foofoo, foofoo, foofoo, - bar, /* - */ /* */ - foo, + bar /* + */, /* */ foo >() - testtest< -/* - */ - foofoo, foofoo, foofoo, /* + testtest() + + testtest() + + testtest() - testtest< - foofoo, foofoo, foofoo, foofoo, - bar,/* - */ - >() - - testtest< - foofoo, foofoo, foofoo, foofoo, bar, // awdawda - >() - - testtest< - foofoo, foofoo, foofoo, foofoo, /* + testtest() - testtest< - foofoo, // fd + testtest() - testtest< - /**/ - foofoo, + testtest< /**/ + foofoo >() - testtest() + testtest() - testtest< - foofoo, foofoo, foofoo, - foofoo,/* - */ /* */ - bar, + testtest() - testtest< - foofoo, // fd + testtest() - testtest< - /**/ - foofoo, + testtest< /**/ + foofoo >() - testtest() + testtest() testtest< foofoo,/* @@ -132,22 +110,15 @@ fun foo() { testtest>, >() - testtest>, /**/testsa>() + testtest>, /**/testsa>() - testtest>/* */, /**/testsa>() + testtest>/* */, /**/testsa>() - testtest< - foofoo, - testtest>,/* - */ - testsa, - >() + testtest>/* + */, testsa>() - testtest>, /**/testsa>() + testtest>, /**/testsa>() - testtest< - foofoo, seee, testtest>, /* - */ - testsa, - >() + testtest>, /* + */testsa>() } \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/typeArguments/TypeArgumentList.call.after.inv.kt b/idea/testData/formatter/trailingComma/typeArguments/TypeArgumentList.call.after.inv.kt new file mode 100644 index 00000000000..4345cac8a65 --- /dev/null +++ b/idea/testData/formatter/trailingComma/typeArguments/TypeArgumentList.call.after.inv.kt @@ -0,0 +1,124 @@ +// SET_TRUE: ALLOW_TRAILING_COMMA + +fun foo() { + testtest< + foofoo, + testtest< + testtest< + foofoo, + >, + >, + testsa, + >() + + testtest() + + testtest< + foofoo, foofoo, foofoo, foofoo, bar + >() + + testtest() + + testtest() + + testtest() + + testtest< + foofoo>() + + testtest< + foofoo + >() + + testtest() + + testtest>>() + + testtest>>() + + testtest< + foofoo, fososos, testtest>, + >() + + testtest>, testsa>() + + testtest>, testsa>() + + testtest< + foofoo, foofoo, foofoo, foofoo, + bar /* + */, /* */ foo + >() + + testtest() + + testtest() + + testtest() + + testtest() + + testtest() + + testtest< /**/ + foofoo + >() + + testtest() + + testtest() + + testtest() + + testtest< /**/ + foofoo + >() + + testtest() + + testtest< + foofoo,/* + */ + >() + + testtest< + foofoo,/**/ + >() + + testtest< + foofoo, fososos,/* + */ + testtest>, + >() + + testtest>, /**/testsa>() + + testtest>/* */, /**/testsa>() + + testtest>/* + */, testsa>() + + testtest>, /**/testsa>() + + testtest>, /* + */testsa>() +} \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/typeArguments/TypeArgumentList.call.after.kt b/idea/testData/formatter/trailingComma/typeArguments/TypeArgumentList.call.after.kt new file mode 100644 index 00000000000..8f5452676a7 --- /dev/null +++ b/idea/testData/formatter/trailingComma/typeArguments/TypeArgumentList.call.after.kt @@ -0,0 +1,153 @@ +// SET_TRUE: ALLOW_TRAILING_COMMA + +fun foo() { + testtest< + foofoo, + testtest< + testtest< + foofoo, + >, + >, + testsa, + >() + + testtest< + foofoo, foofoo, foofoo, + foofoo, bar, + >() + + testtest< + foofoo, foofoo, foofoo, foofoo, bar, + >() + + testtest< + foofoo, foofoo, foofoo, foofoo, bar, + >() + + testtest< + foofoo, foofoo, foofoo, foofoo, + bar, + >() + + testtest< + foofoo, + >() + + testtest< + foofoo, + >() + + testtest< + foofoo, + >() + + testtest() + + testtest>>() + + testtest>>() + + testtest< + foofoo, fososos, testtest>, + >() + + testtest>, testsa>() + + testtest>, testsa>() + + testtest< + foofoo, foofoo, foofoo, foofoo, + bar, /* + */ /* */ + foo, + >() + + testtest< +/* + */ + foofoo, foofoo, foofoo, /* + + */ + foofoo, bar, + >() + + testtest< + foofoo, foofoo, foofoo, foofoo, + bar,/* + */ + >() + + testtest< + foofoo, foofoo, foofoo, foofoo, bar, // awdawda + >() + + testtest< + foofoo, foofoo, foofoo, foofoo, /* + + */ + bar, + >() + + testtest< + foofoo, // fd + >() + + testtest< + /**/ + foofoo, + >() + + testtest() + + testtest< + foofoo, foofoo, foofoo, + foofoo,/* + */ /* */ + bar, + >() + + testtest< + foofoo, // fd + >() + + testtest< + /**/ + foofoo, + >() + + testtest() + + testtest< + foofoo,/* + */ + >() + + testtest< + foofoo,/**/ + >() + + testtest< + foofoo, fososos,/* + */ + testtest>, + >() + + testtest>, /**/testsa>() + + testtest>/* */, /**/testsa>() + + testtest< + foofoo, + testtest>,/* + */ + testsa, + >() + + testtest>, /**/testsa>() + + testtest< + foofoo, seee, testtest>, /* + */ + testsa, + >() +} \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/typeParameters/TypeParameterList.call.after.inv.kt b/idea/testData/formatter/trailingComma/typeParameters/TypeParameterList.call.after.inv.kt new file mode 100644 index 00000000000..4a79a540ec2 --- /dev/null +++ b/idea/testData/formatter/trailingComma/typeParameters/TypeParameterList.call.after.inv.kt @@ -0,0 +1,278 @@ +class A1< + x : String, + y : String, + > + +class F + +class F2 + +class B1< + x : String, + y : String + > + +class C1< + x : String, + y : String, + > + +class D1< + x : String, + y : String, + > + +class A2< + x : String, + y : String, + z : String, + > + +class B2< + x : String, + y : String, + z : String + > + +class C2< + x : String, + y : String, + z : String, + > + +class D2< + x : String, + y : String, + z : String, + > + +class A3< + x : String, + > + +class B3< + x : String + > + +class C3< + x : String, + > + +class D3< + x : String, + > + +class A4< + x : String, + y : String, + z, + > + +class B4< + x : String, + y, + z : String + > + +class C4< + x : String, + y : String, + z : String, + > + +class D4< + x : String, + y, + z : String, + > + +class E1< + x, y : String, + z : String, + > + +class E2< + x : String, y : String, z : String + > + +class C< + z : String, v + + > + +fun < + x : String, + y : String, + > a1() = Unit + +fun b1() = Unit + +fun < + x : String, + y : String, + > c1() = Unit + +fun < + x : String, + y : String, + > d1() = Unit + +fun < + x : String, + y : String, + z : String, + > a2() = Unit + +fun < + x : String, + y : String, + z : String + > b2() = Unit + +fun < + x : String, + y : String, + z : String, + > c2() = Unit + +fun < + x : String, + y : String, + z : String, + > d2() = Unit + +fun < + x : String, + > a3() = Unit + +fun < + x : String + > b3() = Unit + +fun < + x : String, + > c3() = Unit + +fun < + x : String, + > d3() = Unit + +fun < + x : String, + y : String, + z : String, + > a4() = Unit + +fun < + x : String, + y : String, + z : String + > b4() = Unit + +fun < + x : String, + y : String, + z : String, + > c4() = Unit + +fun < + x : String, + y : String, + z : String, + > d4() = Unit + +fun < + x + > foo() { +} + +fun ag() { + +} + +fun ag() { + +} + +fun < + T> ag() { + +} + +class C< + x : Int + > + +class G< + x : String, y : String, /* */ z : String + > + +class G< + x : String, y : String + /* */, /* */ z : String + >() + +class H< + x : String, /* + */ + y : String, + z : String, + > + +class J< + x : String, y : String, + z : String, /* + */ + > + +class K< + x : String, y : String, + z : String, + > + +class L< + x : String, y : String, z : String + > + +class C< + x : Int // adad + > + +class G< + x : String, y : String, /* */ z : String // adad + > + +class G< + x : String, + y : String, + /* */ /* */ + z : String, /**/ + >() + +class H< + x : String, /* + */ + y : String, + z : String, /* + */ + > + +class J< + x : String, y : String, + z : String, /* + */ /**/ + > + +class K< + x : String, y : String, + z : String, // aw + > + +class L< + x : String, y : String, z : String //awd + > + +// SET_TRUE: ALLOW_TRAILING_COMMA diff --git a/idea/testData/formatter/trailingComma/typeParameters/TypeParameterList.call.after.kt b/idea/testData/formatter/trailingComma/typeParameters/TypeParameterList.call.after.kt new file mode 100644 index 00000000000..e6fb9c6bab7 --- /dev/null +++ b/idea/testData/formatter/trailingComma/typeParameters/TypeParameterList.call.after.kt @@ -0,0 +1,287 @@ +class A1< + x : String, + y : String, + > + +class F + +class F2< + x : String, + y + : String, + > + +class B1< + x : String, + y : String, + > + +class C1< + x : String, + y : String, + > + +class D1< + x : String, + y : String, + > + +class A2< + x : String, + y : String, + z : String, + > + +class B2< + x : String, + y : String, + z : String, + > + +class C2< + x : String, + y : String, + z : String, + > + +class D2< + x : String, + y : String, + z : String, + > + +class A3< + x : String, + > + +class B3< + x : String, + > + +class C3< + x : String, + > + +class D3< + x : String, + > + +class A4< + x : String, + y : String, + z, + > + +class B4< + x : String, + y, + z : String, + > + +class C4< + x : String, + y : String, + z : String, + > + +class D4< + x : String, + y, + z : String, + > + +class E1< + x, y : String, + z : String, + > + +class E2< + x : String, y : String, z : String, + > + +class C< + z : String, v, + + > + +fun < + x : String, + y : String, + > a1() = Unit + +fun < + x : String, + y : String, + > b1() = Unit + +fun < + x : String, + y : String, + > c1() = Unit + +fun < + x : String, + y : String, + > d1() = Unit + +fun < + x : String, + y : String, + z : String, + > a2() = Unit + +fun < + x : String, + y : String, + z : String, + > b2() = Unit + +fun < + x : String, + y : String, + z : String, + > c2() = Unit + +fun < + x : String, + y : String, + z : String, + > d2() = Unit + +fun < + x : String, + > a3() = Unit + +fun < + x : String, + > b3() = Unit + +fun < + x : String, + > c3() = Unit + +fun < + x : String, + > d3() = Unit + +fun < + x : String, + y : String, + z : String, + > a4() = Unit + +fun < + x : String, + y : String, + z : String, + > b4() = Unit + +fun < + x : String, + y : String, + z : String, + > c4() = Unit + +fun < + x : String, + y : String, + z : String, + > d4() = Unit + +fun < + x, + > foo() { +} + +fun ag() { + +} + +fun ag() { + +} + +fun < + T, + > ag() { + +} + +class C< + x : Int, + > + +class G< + x : String, y : String, /* */ + z : String, + > + +class G< + x : String, + y : String, + /* */ /* */ + z : String, + >() + +class H< + x : String, /* + */ + y : String, + z : String, + > + +class J< + x : String, y : String, + z : String, /* + */ + > + +class K< + x : String, y : String, + z : String, + > + +class L< + x : String, y : String, z : String, + > + +class C< + x : Int, // adad + > + +class G< + x : String, y : String, /* */ + z : String, // adad + > + +class G< + x : String, + y : String, + /* */ /* */ + z : String, /**/ + >() + +class H< + x : String, /* + */ + y : String, + z : String, /* + */ + > + +class J< + x : String, y : String, + z : String, /* + */ /**/ + > + +class K< + x : String, y : String, + z : String, // aw + > + +class L< + x : String, y : String, z : String, //awd + > + +// SET_TRUE: ALLOW_TRAILING_COMMA diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.after.inv.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.after.inv.kt index 6e536ff0ad8..70971e6e636 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,13 +128,11 @@ 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() { @@ -189,7 +187,7 @@ fun foo() { foofoo ) - testtest(foofoo/**/) + testtest(foofoo,/**/) testtest(foofoo, foofoo, foofoo, foofoo/* */, /* */ bar @@ -202,7 +200,7 @@ fun foo() { foofoo ) - testtest(foofoo/**/) + testtest(foofoo,/**/) testtest( foofoo, fososos,/* @@ -210,16 +208,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 { @@ -267,9 +265,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 b2facd95b5a..70971e6e636 100644 --- a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.after.kt +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.after.kt @@ -2,64 +2,53 @@ // SET_TRUE: ALLOW_TRAILING_COMMA fun foo() { + testtest(foofoo, foofoo, foofoo, + foofoo, bar) + testtest( - foofoo, foofoo, foofoo, - foofoo, bar, + foofoo, foofoo, foofoo, foofoo, bar + ) + + testtest(foofoo, foofoo, foofoo, foofoo, bar + ) + + testtest(foofoo, foofoo, foofoo, foofoo, + bar + ) + + testtest(foofoo ) testtest( - foofoo, foofoo, foofoo, foofoo, bar, - ) + foofoo) testtest( - foofoo, foofoo, foofoo, foofoo, bar, + foofoo ) - testtest( - foofoo, foofoo, foofoo, foofoo, - bar, - ) - - testtest( - foofoo, - ) - - testtest( - foofoo, - ) - - testtest( - 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") }) - useCallable( - "B", "C", - Callable { - println("Hello world") - }, - Callable { - println("Hello world") - }, - ) + useCallable("B", "C", Callable { + println("Hello world") + }, Callable { + println("Hello world") + }) useCallable(Callable { println("Hello world") }) - useCallable(Callable { println("Hello world") }) + useCallable(Callable { println("Hello world") }, ) - useCallable( - Callable { println("Hello world") }, + useCallable(Callable { println("Hello world") } ) useCallable(Callable { println("Hello world") }) { @@ -67,27 +56,21 @@ fun foo() { } useCallable( - Callable { println("Hello world") }, - ) + Callable { println("Hello world") }) useCallable("A", { println("Hello world") }) - useCallable( - "B", "C", - { - println("Hello world") - }, - { - println("Hello world") - }, - ) + useCallable("B", "C", { + println("Hello world") + }, { + println("Hello world") + }) useCallable({ println("Hello world") }) - useCallable({ println("Hello world") }) + useCallable({ println("Hello world") }, ) - useCallable( - { println("Hello world") }, + useCallable({ println("Hello world") } ) useCallable({ println("Hello world") }) { @@ -95,27 +78,21 @@ fun foo() { } useCallable( - { println("Hello world") }, - ) + { println("Hello world") }) useCallable("A", foo() { println("Hello world") }) - useCallable( - "B", "C", - foo() { - println("Hello world") - }, - foo() { - println("Hello world") - }, - ) + useCallable("B", "C", foo() { + println("Hello world") + }, foo() { + println("Hello world") + }) useCallable(foo() { println("Hello world") }) - useCallable(foo() { println("Hello world") }) + useCallable(foo() { println("Hello world") }, ) - useCallable( - foo() { println("Hello world") }, + useCallable(foo() { println("Hello world") } ) useCallable(foo() { println("Hello world") }) { @@ -123,70 +100,52 @@ fun foo() { } useCallable( - foo() { println("Hello world") }, + foo() { println("Hello world") }) + + useCallable("A", object : Callable { + override fun call() { + println("Hello world") + } + }) + + useCallable("A", object : Callable { + override fun call() { + println("Hello world") + } + }) + + useCallable("B", "C", object : Callable { + override fun call() { + println("Hello world") + } + }, foo() { + println("Hello world") + }) + + useCallable(object : Callable { + override fun call() { + println("Hello world") + } + }) + + useCallable(object : Callable { + override fun call() { + println("Hello world") + } + }, ) + + useCallable(object : Callable { + override fun call() { + println("Hello world") + } + } ) - useCallable( - "A", - object : Callable { - override fun call() { - println("Hello world") - } - }, - ) - - useCallable( - "A", - object : Callable { - override fun call() { - println("Hello world") - } - }, - ) - - useCallable( - "B", "C", - object : Callable { - override fun call() { - println("Hello world") - } - }, - foo() { - println("Hello world") - }, - ) - - useCallable( - object : Callable { - override fun call() { - println("Hello world") - } - }, - ) - - useCallable( - object : Callable { - override fun call() { - println("Hello world") - } - }, - ) - - useCallable( - object : Callable { - override fun call() { - println("Hello world") - } - }, - ) - - useCallable( - object : Callable { - override fun call() { - println("Hello world") - } - }, - ) { + useCallable(object : Callable { + override fun call() { + println("Hello world") + } + }) { } @@ -195,70 +154,53 @@ fun foo() { override fun call() { println("Hello world") } - }, - ) + }) testtest( foofoo, foofoo, foofoo, foofoo, - bar, /* - */ /* */ - foo, + bar /* + */, /* */ foo ) - testtest( -/* - */ - foofoo, foofoo, foofoo, /* + testtest(/* + */foofoo, foofoo, foofoo, /* */ - foofoo, bar, + foofoo, bar) + + testtest(foofoo, foofoo, foofoo, foofoo, bar/* + */) + + testtest(foofoo, foofoo, foofoo, foofoo, bar // awdawda ) - testtest( - foofoo, foofoo, foofoo, foofoo, - bar,/* - */ - ) - - testtest( - foofoo, foofoo, foofoo, foofoo, bar, // awdawda - ) - - testtest( - foofoo, foofoo, foofoo, foofoo, /* + testtest(foofoo, foofoo, foofoo, foofoo, /* */ - bar, + bar ) - testtest( - foofoo, // fd + testtest(foofoo // fd ) - testtest( - /**/ - foofoo, + testtest( /**/ + foofoo ) - testtest(foofoo/**/) + testtest(foofoo,/**/) - testtest( - foofoo, foofoo, foofoo, - foofoo,/* - */ /* */ - bar, + testtest(foofoo, foofoo, foofoo, foofoo/* + */, /* */ bar ) - testtest( - foofoo, // fd + testtest(foofoo // fd ) - testtest( - /**/ - foofoo, + testtest( /**/ + foofoo ) - testtest(foofoo/**/) + testtest(foofoo,/**/) testtest( foofoo, fososos,/* @@ -266,37 +208,25 @@ 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") - }, /* */ - Callable { - println("Hello world") - }, - ) + useCallable("B", "C", Callable { + println("Hello world") + }, /* */ Callable { + println("Hello world") + }) - useCallable( - Callable { println("Hello world") }, // ffd + useCallable(Callable { println("Hello world") } // ffd ) useCallable( @@ -323,15 +253,9 @@ fun foo() { Callable { println("Hello world") }, ) - testtest( + testtest(foofoo, testtest(testtest( foofoo, - testtest( - testtest( - foofoo, - ), - ), - testsa, - ) + )), testsa) testtest( foofoo, fososos, testtest(testtest(foofoo)), @@ -341,9 +265,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 a54b1b7e946..76f77d2f511 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,13 +128,11 @@ 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() { @@ -189,7 +187,7 @@ fun foo() { foofoo ) - testtest(foofoo/**/) + testtest(foofoo,/**/) testtest(foofoo, foofoo, foofoo, foofoo/* */, /* */ bar @@ -202,7 +200,7 @@ fun foo() { foofoo ) - testtest(foofoo/**/) + testtest(foofoo,/**/) testtest( foofoo, fososos,/* @@ -210,16 +208,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 { @@ -267,9 +265,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 f7c5c3c7bcc..76f77d2f511 100644 --- a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.after.kt +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.after.kt @@ -2,64 +2,53 @@ // SET_TRUE: ALLOW_TRAILING_COMMA fun foo() { + testtest(foofoo, foofoo, foofoo, + foofoo, bar) + testtest( - foofoo, foofoo, foofoo, - foofoo, bar, + foofoo, foofoo, foofoo, foofoo, bar + ) + + testtest(foofoo, foofoo, foofoo, foofoo, bar + ) + + testtest(foofoo, foofoo, foofoo, foofoo, + bar + ) + + testtest(foofoo ) testtest( - foofoo, foofoo, foofoo, foofoo, bar, - ) + foofoo) testtest( - foofoo, foofoo, foofoo, foofoo, bar, + foofoo ) - testtest( - foofoo, foofoo, foofoo, foofoo, - bar, - ) - - testtest( - foofoo, - ) - - testtest( - foofoo, - ) - - testtest( - 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") }) - useCallable( - "B", "C", - Callable { - println("Hello world") - }, - Callable { - println("Hello world") - }, - ) + useCallable("B", "C", Callable { + println("Hello world") + }, Callable { + println("Hello world") + }) useCallable(Callable { println("Hello world") }) - useCallable(Callable { println("Hello world") }) + useCallable(Callable { println("Hello world") }, ) - useCallable( - Callable { println("Hello world") }, + useCallable(Callable { println("Hello world") } ) useCallable(Callable { println("Hello world") }) { @@ -67,27 +56,21 @@ fun foo() { } useCallable( - Callable { println("Hello world") }, - ) + Callable { println("Hello world") }) useCallable("A", { println("Hello world") }) - useCallable( - "B", "C", - { - println("Hello world") - }, - { - println("Hello world") - }, - ) + useCallable("B", "C", { + println("Hello world") + }, { + println("Hello world") + }) useCallable({ println("Hello world") }) - useCallable({ println("Hello world") }) + useCallable({ println("Hello world") }, ) - useCallable( - { println("Hello world") }, + useCallable({ println("Hello world") } ) useCallable({ println("Hello world") }) { @@ -95,27 +78,21 @@ fun foo() { } useCallable( - { println("Hello world") }, - ) + { println("Hello world") }) useCallable("A", foo() { println("Hello world") }) - useCallable( - "B", "C", - foo() { - println("Hello world") - }, - foo() { - println("Hello world") - }, - ) + useCallable("B", "C", foo() { + println("Hello world") + }, foo() { + println("Hello world") + }) useCallable(foo() { println("Hello world") }) - useCallable(foo() { println("Hello world") }) + useCallable(foo() { println("Hello world") }, ) - useCallable( - foo() { println("Hello world") }, + useCallable(foo() { println("Hello world") } ) useCallable(foo() { println("Hello world") }) { @@ -123,70 +100,52 @@ fun foo() { } useCallable( - foo() { println("Hello world") }, + foo() { println("Hello world") }) + + useCallable("A", object : Callable { + override fun call() { + println("Hello world") + } + }) + + useCallable("A", object : Callable { + override fun call() { + println("Hello world") + } + }) + + useCallable("B", "C", object : Callable { + override fun call() { + println("Hello world") + } + }, foo() { + println("Hello world") + }) + + useCallable(object : Callable { + override fun call() { + println("Hello world") + } + }) + + useCallable(object : Callable { + override fun call() { + println("Hello world") + } + }, ) + + useCallable(object : Callable { + override fun call() { + println("Hello world") + } + } ) - useCallable( - "A", - object : Callable { - override fun call() { - println("Hello world") - } - }, - ) - - useCallable( - "A", - object : Callable { - override fun call() { - println("Hello world") - } - }, - ) - - useCallable( - "B", "C", - object : Callable { - override fun call() { - println("Hello world") - } - }, - foo() { - println("Hello world") - }, - ) - - useCallable( - object : Callable { - override fun call() { - println("Hello world") - } - }, - ) - - useCallable( - object : Callable { - override fun call() { - println("Hello world") - } - }, - ) - - useCallable( - object : Callable { - override fun call() { - println("Hello world") - } - }, - ) - - useCallable( - object : Callable { - override fun call() { - println("Hello world") - } - }, - ) { + useCallable(object : Callable { + override fun call() { + println("Hello world") + } + }) { } @@ -195,70 +154,53 @@ fun foo() { override fun call() { println("Hello world") } - }, - ) + }) testtest( foofoo, foofoo, foofoo, foofoo, - bar, /* - */ /* */ - foo, + bar /* + */, /* */ foo ) - testtest( -/* - */ - foofoo, foofoo, foofoo, /* + testtest(/* + */foofoo, foofoo, foofoo, /* */ - foofoo, bar, + foofoo, bar) + + testtest(foofoo, foofoo, foofoo, foofoo, bar/* + */) + + testtest(foofoo, foofoo, foofoo, foofoo, bar // awdawda ) - testtest( - foofoo, foofoo, foofoo, foofoo, - bar,/* - */ - ) - - testtest( - foofoo, foofoo, foofoo, foofoo, bar, // awdawda - ) - - testtest( - foofoo, foofoo, foofoo, foofoo, /* + testtest(foofoo, foofoo, foofoo, foofoo, /* */ - bar, + bar ) - testtest( - foofoo, // fd + testtest(foofoo // fd ) - testtest( - /**/ - foofoo, + testtest( /**/ + foofoo ) - testtest(foofoo/**/) + testtest(foofoo,/**/) - testtest( - foofoo, foofoo, foofoo, - foofoo,/* - */ /* */ - bar, + testtest(foofoo, foofoo, foofoo, foofoo/* + */, /* */ bar ) - testtest( - foofoo, // fd + testtest(foofoo // fd ) - testtest( - /**/ - foofoo, + testtest( /**/ + foofoo ) - testtest(foofoo/**/) + testtest(foofoo,/**/) testtest( foofoo, fososos,/* @@ -266,37 +208,25 @@ 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") - }, /* */ - Callable { - println("Hello world") - }, - ) + useCallable("B", "C", Callable { + println("Hello world") + }, /* */ Callable { + println("Hello world") + }) - useCallable( - Callable { println("Hello world") }, // ffd + useCallable(Callable { println("Hello world") } // ffd ) useCallable( @@ -323,15 +253,9 @@ fun foo() { Callable { println("Hello world") }, ) - testtest( + testtest(foofoo, testtest(testtest( foofoo, - testtest( - testtest( - foofoo, - ), - ), - testsa, - ) + )), testsa) testtest( foofoo, fososos, testtest(testtest(foofoo)), @@ -341,9 +265,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 c5bf8b4dea2..823ffb15464 100644 --- a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.after.inv.kt +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.after.inv.kt @@ -50,24 +50,22 @@ 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", @@ -84,7 +82,7 @@ fun foo() { useCallable(Callable { println("Hello world") }) - useCallable(Callable { println("Hello world") }) + useCallable(Callable { println("Hello world") }, ) useCallable(Callable { println("Hello world") } ) @@ -110,7 +108,7 @@ fun foo() { useCallable({ println("Hello world") }) - useCallable({ println("Hello world") }) + useCallable({ println("Hello world") }, ) useCallable({ println("Hello world") } ) @@ -136,7 +134,7 @@ fun foo() { useCallable(foo() { println("Hello world") }) - useCallable(foo() { println("Hello world") }) + useCallable(foo() { println("Hello world") }, ) useCallable(foo() { println("Hello world") } ) @@ -179,13 +177,11 @@ 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() { @@ -258,7 +254,7 @@ fun foo() { foofoo ) - testtest(foofoo/**/) + testtest(foofoo,/**/) testtest(foofoo, foofoo, @@ -275,7 +271,7 @@ fun foo() { foofoo ) - testtest(foofoo/**/) + testtest(foofoo,/**/) testtest( foofoo, @@ -285,26 +281,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) @@ -360,9 +356,9 @@ fun foo() { fun test() { baz( - f = fun(it: Int): String = "$it", /*dwdwd - */ - name = "", /* - */ + f = fun(it: Int): String = "$it" /*dwdwd + */, + name = "" /* + */, ) -} \ 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 b7174ceffb6..823ffb15464 100644 --- a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.after.kt +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.after.kt @@ -12,98 +12,79 @@ fun foo() { testsa, ) + testtest(foofoo, + foofoo, + foofoo, + foofoo, + bar) + testtest( foofoo, foofoo, foofoo, foofoo, - bar, + bar + ) + + testtest(foofoo, + foofoo, + foofoo, + foofoo, + bar + ) + + testtest(foofoo, + foofoo, + foofoo, + foofoo, + bar + ) + + testtest(foofoo ) testtest( - foofoo, - foofoo, - foofoo, - foofoo, - bar, - ) + foofoo) testtest( - foofoo, - foofoo, - foofoo, - foofoo, - bar, + foofoo ) - testtest( - foofoo, - foofoo, - foofoo, - foofoo, - bar, - ) + testtest(foofoo, ) - testtest( - foofoo, - ) + testtest(foofoo, + testtest(testtest(foofoo))) - testtest( - 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)), - testsa, - ) + testtest(foofoo, + testtest(testtest(foofoo, )), + testsa) - testtest( - foofoo, + testtest(foofoo, seee, - testtest(testtest(foofoo)), - testsa, - ) + testtest(testtest(foofoo, )), + testsa) - useCallable( - "A", - Callable { println("Hello world") }, - ) + useCallable("A", + Callable { println("Hello world") }) - useCallable( - "B", + useCallable("B", "C", Callable { println("Hello world") }, Callable { println("Hello world") - }, - ) + }) useCallable(Callable { println("Hello world") }) - useCallable(Callable { println("Hello world") }) + useCallable(Callable { println("Hello world") }, ) - useCallable( - Callable { println("Hello world") }, + useCallable(Callable { println("Hello world") } ) useCallable(Callable { println("Hello world") }) { @@ -111,31 +92,25 @@ fun foo() { } useCallable( - Callable { println("Hello world") }, - ) + Callable { println("Hello world") }) - useCallable( - "A", - { println("Hello world") }, - ) + useCallable("A", + { println("Hello world") }) - useCallable( - "B", + useCallable("B", "C", { println("Hello world") }, { println("Hello world") - }, - ) + }) useCallable({ println("Hello world") }) - useCallable({ println("Hello world") }) + useCallable({ println("Hello world") }, ) - useCallable( - { println("Hello world") }, + useCallable({ println("Hello world") } ) useCallable({ println("Hello world") }) { @@ -143,31 +118,25 @@ fun foo() { } useCallable( - { println("Hello world") }, - ) + { println("Hello world") }) - useCallable( - "A", - foo() { println("Hello world") }, - ) + useCallable("A", + foo() { println("Hello world") }) - useCallable( - "B", + useCallable("B", "C", foo() { println("Hello world") }, foo() { println("Hello world") - }, - ) + }) useCallable(foo() { println("Hello world") }) - useCallable(foo() { println("Hello world") }) + useCallable(foo() { println("Hello world") }, ) - useCallable( - foo() { println("Hello world") }, + useCallable(foo() { println("Hello world") } ) useCallable(foo() { println("Hello world") }) { @@ -175,29 +144,23 @@ fun foo() { } useCallable( - foo() { println("Hello world") }, - ) + foo() { println("Hello world") }) - useCallable( - "A", + useCallable("A", object : Callable { override fun call() { println("Hello world") } - }, - ) + }) - useCallable( - "A", + useCallable("A", object : Callable { override fun call() { println("Hello world") } - }, - ) + }) - useCallable( - "B", + useCallable("B", "C", object : Callable { override fun call() { @@ -206,40 +169,32 @@ fun foo() { }, foo() { println("Hello world") - }, + }) + + useCallable(object : Callable { + override fun call() { + println("Hello world") + } + }) + + useCallable(object : Callable { + override fun call() { + println("Hello world") + } + }, ) + + useCallable(object : Callable { + override fun call() { + println("Hello world") + } + } ) - useCallable( - object : Callable { - override fun call() { - println("Hello world") - } - }, - ) - - useCallable( - object : Callable { - override fun call() { - println("Hello world") - } - }, - ) - - useCallable( - object : Callable { - override fun call() { - println("Hello world") - } - }, - ) - - useCallable( - object : Callable { - override fun call() { - println("Hello world") - } - }, - ) { + useCallable(object : Callable { + override fun call() { + println("Hello world") + } + }) { } @@ -248,88 +203,75 @@ fun foo() { override fun call() { println("Hello world") } - }, - ) + }) testtest( foofoo, foofoo, foofoo, foofoo, - bar, /* - */ /* */ - foo, + bar /* + */, /* */ + foo ) - testtest( -/* - */ - foofoo, + testtest(/* + */foofoo, foofoo, foofoo, /* */ foofoo, - bar, + bar) + + testtest(foofoo, + foofoo, + foofoo, + foofoo, + bar/* + */) + + testtest(foofoo, + foofoo, + foofoo, + foofoo, + bar // awdawda ) - testtest( - foofoo, - foofoo, - foofoo, - foofoo, - bar,/* - */ - ) - - testtest( - foofoo, - foofoo, - foofoo, - foofoo, - bar, // awdawda - ) - - testtest( - foofoo, + testtest(foofoo, foofoo, foofoo, foofoo, /* */ - bar, + bar ) - testtest( - foofoo, // fd + testtest(foofoo // fd ) - testtest( - /**/ - foofoo, + testtest( /**/ + foofoo ) - testtest(foofoo/**/) + testtest(foofoo,/**/) - testtest( + testtest(foofoo, foofoo, foofoo, - foofoo, - foofoo,/* - */ /* */ - bar, + foofoo/* + */, /* */ + bar ) - testtest( - foofoo, // fd + testtest(foofoo // fd ) - testtest( - /**/ - foofoo, + testtest( /**/ + foofoo ) - testtest(foofoo/**/) + testtest(foofoo,/**/) testtest( foofoo, @@ -338,53 +280,40 @@ 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, + testtest(foofoo, seee, - testtest(testtest(foofoo)), /**/ - testsa, - ) + testtest(testtest(foofoo, )), /**/ + testsa) - testtest( - foofoo, + testtest(foofoo, seee, - testtest(testtest(foofoo)), /* + testtest(testtest(foofoo, )), /* */ - testsa, - ) + testsa) - useCallable( - "B", + useCallable("B", "C", Callable { println("Hello world") }, /* */ Callable { println("Hello world") - }, - ) + }) - useCallable( - Callable { println("Hello world") }, // ffd + useCallable(Callable { println("Hello world") } // ffd ) useCallable( @@ -411,15 +340,11 @@ fun foo() { Callable { println("Hello world") }, ) - testtest( - foofoo, - testtest( - testtest( - foofoo, - ), - ), - testsa, - ) + testtest(foofoo, + testtest(testtest( + foofoo, + )), + testsa) testtest( foofoo, @@ -431,9 +356,9 @@ fun foo() { fun test() { baz( - f = fun(it: Int): String = "$it", /*dwdwd - */ - name = "", /* - */ + f = fun(it: Int): String = "$it" /*dwdwd + */, + name = "" /* + */, ) -} \ 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 5d5ec47e5e8..86f8b85db57 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,13 +128,11 @@ 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() { @@ -189,7 +187,7 @@ fun foo() { foofoo ) - testtest(foofoo/**/) + testtest(foofoo,/**/) testtest(foofoo, foofoo, foofoo, foofoo/* */, /* */ bar @@ -202,7 +200,7 @@ fun foo() { foofoo ) - testtest(foofoo/**/) + testtest(foofoo,/**/) testtest( foofoo, fososos,/* @@ -210,16 +208,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 { @@ -267,9 +265,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 a7c0cc626d2..86f8b85db57 100644 --- a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.after.kt +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.after.kt @@ -2,64 +2,53 @@ // SET_TRUE: ALLOW_TRAILING_COMMA fun foo() { + testtest(foofoo, foofoo, foofoo, + foofoo, bar) + testtest( - foofoo, foofoo, foofoo, - foofoo, bar, + foofoo, foofoo, foofoo, foofoo, bar + ) + + testtest(foofoo, foofoo, foofoo, foofoo, bar + ) + + testtest(foofoo, foofoo, foofoo, foofoo, + bar + ) + + testtest(foofoo ) testtest( - foofoo, foofoo, foofoo, foofoo, bar, - ) + foofoo) testtest( - foofoo, foofoo, foofoo, foofoo, bar, + foofoo ) - testtest( - foofoo, foofoo, foofoo, foofoo, - bar, - ) - - testtest( - foofoo, - ) - - testtest( - foofoo, - ) - - testtest( - 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") }) - useCallable( - "B", "C", - Callable { - println("Hello world") - }, - Callable { - println("Hello world") - }, - ) + useCallable("B", "C", Callable { + println("Hello world") + }, Callable { + println("Hello world") + }) useCallable(Callable { println("Hello world") }) - useCallable(Callable { println("Hello world") }) + useCallable(Callable { println("Hello world") }, ) - useCallable( - Callable { println("Hello world") }, + useCallable(Callable { println("Hello world") } ) useCallable(Callable { println("Hello world") }) { @@ -67,27 +56,21 @@ fun foo() { } useCallable( - Callable { println("Hello world") }, - ) + Callable { println("Hello world") }) useCallable("A", { println("Hello world") }) - useCallable( - "B", "C", - { - println("Hello world") - }, - { - println("Hello world") - }, - ) + useCallable("B", "C", { + println("Hello world") + }, { + println("Hello world") + }) useCallable({ println("Hello world") }) - useCallable({ println("Hello world") }) + useCallable({ println("Hello world") }, ) - useCallable( - { println("Hello world") }, + useCallable({ println("Hello world") } ) useCallable({ println("Hello world") }) { @@ -95,27 +78,21 @@ fun foo() { } useCallable( - { println("Hello world") }, - ) + { println("Hello world") }) useCallable("A", foo() { println("Hello world") }) - useCallable( - "B", "C", - foo() { - println("Hello world") - }, - foo() { - println("Hello world") - }, - ) + useCallable("B", "C", foo() { + println("Hello world") + }, foo() { + println("Hello world") + }) useCallable(foo() { println("Hello world") }) - useCallable(foo() { println("Hello world") }) + useCallable(foo() { println("Hello world") }, ) - useCallable( - foo() { println("Hello world") }, + useCallable(foo() { println("Hello world") } ) useCallable(foo() { println("Hello world") }) { @@ -123,70 +100,52 @@ fun foo() { } useCallable( - foo() { println("Hello world") }, + foo() { println("Hello world") }) + + useCallable("A", object : Callable { + override fun call() { + println("Hello world") + } + }) + + useCallable("A", object : Callable { + override fun call() { + println("Hello world") + } + }) + + useCallable("B", "C", object : Callable { + override fun call() { + println("Hello world") + } + }, foo() { + println("Hello world") + }) + + useCallable(object : Callable { + override fun call() { + println("Hello world") + } + }) + + useCallable(object : Callable { + override fun call() { + println("Hello world") + } + }, ) + + useCallable(object : Callable { + override fun call() { + println("Hello world") + } + } ) - useCallable( - "A", - object : Callable { - override fun call() { - println("Hello world") - } - }, - ) - - useCallable( - "A", - object : Callable { - override fun call() { - println("Hello world") - } - }, - ) - - useCallable( - "B", "C", - object : Callable { - override fun call() { - println("Hello world") - } - }, - foo() { - println("Hello world") - }, - ) - - useCallable( - object : Callable { - override fun call() { - println("Hello world") - } - }, - ) - - useCallable( - object : Callable { - override fun call() { - println("Hello world") - } - }, - ) - - useCallable( - object : Callable { - override fun call() { - println("Hello world") - } - }, - ) - - useCallable( - object : Callable { - override fun call() { - println("Hello world") - } - }, - ) { + useCallable(object : Callable { + override fun call() { + println("Hello world") + } + }) { } @@ -195,70 +154,53 @@ fun foo() { override fun call() { println("Hello world") } - }, - ) + }) testtest( foofoo, foofoo, foofoo, foofoo, - bar, /* - */ /* */ - foo, + bar /* + */, /* */ foo ) - testtest( -/* - */ - foofoo, foofoo, foofoo, /* + testtest(/* + */foofoo, foofoo, foofoo, /* */ - foofoo, bar, + foofoo, bar) + + testtest(foofoo, foofoo, foofoo, foofoo, bar/* + */) + + testtest(foofoo, foofoo, foofoo, foofoo, bar // awdawda ) - testtest( - foofoo, foofoo, foofoo, foofoo, - bar,/* - */ - ) - - testtest( - foofoo, foofoo, foofoo, foofoo, bar, // awdawda - ) - - testtest( - foofoo, foofoo, foofoo, foofoo, /* + testtest(foofoo, foofoo, foofoo, foofoo, /* */ - bar, + bar ) - testtest( - foofoo, // fd + testtest(foofoo // fd ) - testtest( - /**/ - foofoo, + testtest( /**/ + foofoo ) - testtest(foofoo/**/) + testtest(foofoo,/**/) - testtest( - foofoo, foofoo, foofoo, - foofoo,/* - */ /* */ - bar, + testtest(foofoo, foofoo, foofoo, foofoo/* + */, /* */ bar ) - testtest( - foofoo, // fd + testtest(foofoo // fd ) - testtest( - /**/ - foofoo, + testtest( /**/ + foofoo ) - testtest(foofoo/**/) + testtest(foofoo,/**/) testtest( foofoo, fososos,/* @@ -266,37 +208,25 @@ 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") - }, /* */ - Callable { - println("Hello world") - }, - ) + useCallable("B", "C", Callable { + println("Hello world") + }, /* */ Callable { + println("Hello world") + }) - useCallable( - Callable { println("Hello world") }, // ffd + useCallable(Callable { println("Hello world") } // ffd ) useCallable( @@ -323,15 +253,9 @@ fun foo() { Callable { println("Hello world") }, ) - testtest( + testtest(foofoo, testtest(testtest( foofoo, - testtest( - testtest( - foofoo, - ), - ), - testsa, - ) + )), testsa) testtest( foofoo, fososos, testtest(testtest(foofoo)), @@ -341,9 +265,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.call.after.inv.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.call.after.inv.kt new file mode 100644 index 00000000000..5d5ec47e5e8 --- /dev/null +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.call.after.inv.kt @@ -0,0 +1,275 @@ +// SET_INT: CALL_PARAMETERS_WRAP = 1 +// SET_TRUE: ALLOW_TRAILING_COMMA + +fun foo() { + testtest(foofoo, foofoo, foofoo, + foofoo, bar) + + testtest( + foofoo, foofoo, foofoo, foofoo, bar + ) + + testtest(foofoo, foofoo, foofoo, foofoo, bar + ) + + testtest(foofoo, foofoo, foofoo, foofoo, + bar + ) + + testtest(foofoo + ) + + testtest( + foofoo) + + testtest( + foofoo + ) + + testtest(foofoo) + + testtest(foofoo, testtest(testtest(foofoo))) + + testtest(foofoo, fososos, testtest(testtest(foofoo))) + + testtest(foofoo, testtest(testtest(foofoo)), testsa) + + testtest(foofoo, seee, testtest(testtest(foofoo)), testsa) + + useCallable("A", Callable { println("Hello world") }) + + useCallable("B", "C", Callable { + println("Hello world") + }, Callable { + println("Hello world") + }) + + useCallable(Callable { println("Hello world") }) + + useCallable(Callable { println("Hello world") }) + + useCallable(Callable { println("Hello world") } + ) + + useCallable(Callable { println("Hello world") }) { + + } + + useCallable( + Callable { println("Hello world") }) + + useCallable("A", { println("Hello world") }) + + useCallable("B", "C", { + println("Hello world") + }, { + println("Hello world") + }) + + useCallable({ println("Hello world") }) + + useCallable({ println("Hello world") }) + + useCallable({ println("Hello world") } + ) + + useCallable({ println("Hello world") }) { + + } + + useCallable( + { println("Hello world") }) + + useCallable("A", foo() { println("Hello world") }) + + useCallable("B", "C", foo() { + println("Hello world") + }, foo() { + println("Hello world") + }) + + useCallable(foo() { println("Hello world") }) + + useCallable(foo() { println("Hello world") }) + + useCallable(foo() { println("Hello world") } + ) + + useCallable(foo() { println("Hello world") }) { + + } + + useCallable( + foo() { println("Hello world") }) + + useCallable("A", object : Callable { + override fun call() { + println("Hello world") + } + }) + + useCallable("A", object : Callable { + override fun call() { + println("Hello world") + } + }) + + useCallable("B", "C", object : Callable { + override fun call() { + println("Hello world") + } + }, foo() { + println("Hello world") + }) + + useCallable(object : Callable { + override fun call() { + println("Hello world") + } + }) + + useCallable( + object : Callable { + override fun call() { + println("Hello world") + } + }, + ) + + useCallable(object : Callable { + override fun call() { + println("Hello world") + } + } + ) + + useCallable(object : Callable { + override fun call() { + println("Hello world") + } + }) { + + } + + useCallable( + object : Callable { + override fun call() { + println("Hello world") + } + }) + + testtest( + foofoo, foofoo, foofoo, foofoo, + bar /* + */, /* */ foo + ) + + testtest(/* + */foofoo, foofoo, foofoo, /* + + */ + foofoo, bar) + + testtest(foofoo, foofoo, foofoo, foofoo, bar/* + */) + + testtest(foofoo, foofoo, foofoo, foofoo, bar // awdawda + ) + + testtest(foofoo, foofoo, foofoo, foofoo, /* + + */ + bar + ) + + testtest(foofoo // fd + ) + + testtest( /**/ + foofoo + ) + + testtest(foofoo/**/) + + testtest(foofoo, foofoo, foofoo, foofoo/* + */, /* */ bar + ) + + testtest(foofoo // fd + ) + + testtest( /**/ + foofoo + ) + + testtest(foofoo/**/) + + testtest( + foofoo, fososos,/* + */ + testtest(testtest(foofoo)), + ) + + 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) + + useCallable("B", "C", Callable { + println("Hello world") + }, /* */ Callable { + println("Hello world") + }) + + 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)), + ) + +} + +fun test() { + baz( + f = fun(it: Int): String = "$it", /*dwdwd + */ + name = "", /* + */ + ) +} diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.call.after.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.call.after.kt new file mode 100644 index 00000000000..a7c0cc626d2 --- /dev/null +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.call.after.kt @@ -0,0 +1,349 @@ +// SET_INT: CALL_PARAMETERS_WRAP = 1 +// SET_TRUE: ALLOW_TRAILING_COMMA + +fun foo() { + testtest( + foofoo, foofoo, foofoo, + foofoo, bar, + ) + + testtest( + foofoo, foofoo, foofoo, foofoo, bar, + ) + + testtest( + foofoo, foofoo, foofoo, foofoo, bar, + ) + + testtest( + foofoo, foofoo, foofoo, foofoo, + bar, + ) + + testtest( + foofoo, + ) + + testtest( + foofoo, + ) + + testtest( + foofoo, + ) + + testtest(foofoo) + + testtest(foofoo, testtest(testtest(foofoo))) + + testtest(foofoo, fososos, testtest(testtest(foofoo))) + + testtest(foofoo, testtest(testtest(foofoo)), testsa) + + testtest(foofoo, seee, testtest(testtest(foofoo)), testsa) + + useCallable("A", Callable { println("Hello world") }) + + useCallable( + "B", "C", + Callable { + println("Hello world") + }, + Callable { + println("Hello world") + }, + ) + + useCallable(Callable { println("Hello world") }) + + useCallable(Callable { println("Hello world") }) + + useCallable( + Callable { println("Hello world") }, + ) + + useCallable(Callable { println("Hello world") }) { + + } + + useCallable( + Callable { println("Hello world") }, + ) + + useCallable("A", { println("Hello world") }) + + useCallable( + "B", "C", + { + println("Hello world") + }, + { + println("Hello world") + }, + ) + + useCallable({ println("Hello world") }) + + useCallable({ println("Hello world") }) + + useCallable( + { println("Hello world") }, + ) + + useCallable({ println("Hello world") }) { + + } + + useCallable( + { println("Hello world") }, + ) + + useCallable("A", foo() { println("Hello world") }) + + useCallable( + "B", "C", + foo() { + println("Hello world") + }, + foo() { + println("Hello world") + }, + ) + + useCallable(foo() { println("Hello world") }) + + useCallable(foo() { println("Hello world") }) + + useCallable( + foo() { println("Hello world") }, + ) + + useCallable(foo() { println("Hello world") }) { + + } + + useCallable( + foo() { println("Hello world") }, + ) + + useCallable( + "A", + object : Callable { + override fun call() { + println("Hello world") + } + }, + ) + + useCallable( + "A", + object : Callable { + override fun call() { + println("Hello world") + } + }, + ) + + useCallable( + "B", "C", + object : Callable { + override fun call() { + println("Hello world") + } + }, + foo() { + println("Hello world") + }, + ) + + useCallable( + object : Callable { + override fun call() { + println("Hello world") + } + }, + ) + + useCallable( + object : Callable { + override fun call() { + println("Hello world") + } + }, + ) + + useCallable( + object : Callable { + override fun call() { + println("Hello world") + } + }, + ) + + useCallable( + object : Callable { + override fun call() { + println("Hello world") + } + }, + ) { + + } + + useCallable( + object : Callable { + override fun call() { + println("Hello world") + } + }, + ) + + testtest( + foofoo, foofoo, foofoo, foofoo, + bar, /* + */ /* */ + foo, + ) + + testtest( +/* + */ + foofoo, foofoo, foofoo, /* + + */ + foofoo, bar, + ) + + testtest( + foofoo, foofoo, foofoo, foofoo, + bar,/* + */ + ) + + testtest( + foofoo, foofoo, foofoo, foofoo, bar, // awdawda + ) + + testtest( + foofoo, foofoo, foofoo, foofoo, /* + + */ + bar, + ) + + testtest( + foofoo, // fd + ) + + testtest( + /**/ + foofoo, + ) + + testtest(foofoo/**/) + + testtest( + foofoo, foofoo, foofoo, + foofoo,/* + */ /* */ + bar, + ) + + testtest( + foofoo, // fd + ) + + testtest( + /**/ + foofoo, + ) + + testtest(foofoo/**/) + + testtest( + foofoo, fososos,/* + */ + testtest(testtest(foofoo)), + ) + + 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, + ) + + useCallable( + "B", "C", + Callable { + println("Hello world") + }, /* */ + Callable { + println("Hello world") + }, + ) + + 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)), + ) + +} + +fun test() { + baz( + f = fun(it: Int): String = "$it", /*dwdwd + */ + name = "", /* + */ + ) +} diff --git a/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAsNeeded.call.after.inv.kt b/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAsNeeded.call.after.inv.kt new file mode 100644 index 00000000000..cbab4d9d86b --- /dev/null +++ b/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAsNeeded.call.after.inv.kt @@ -0,0 +1,479 @@ +class A1 { + val x: String + val y: String + + constructor( + x: String, + y: String, + ) { + this.x = x + this.y = y + } +} + +class B1 { + val x: String + val y: String + + constructor( + x: String, + y: String + ) { + this.x = x + this.y = y + } +} + +class C1 { + val x: String + val y: String + + constructor( + x: String, + y: String, + ) { + this.x = x + this.y = y + } +} + +class D1 { + val x: String + val y: String + + constructor( + x: String, + y: String, + ) { + this.x = x + this.y = y + } +} + +class A2 { + val x: String + val y: String + val z: String + + constructor( + x: String, + y: String, + z: String, + ) { + this.x = x + this.y = y + this.z = z + } +} + +class B2 { + val x: String + val y: String + val z: String + + constructor( + x: String, + y: String, + z: String + ) { + this.x = x + this.y = y + this.z = z + } +} + +class C2 { + val x: String + val y: String + val z: String + + constructor( + x: String, + y: String, + z: String, + ) { + this.x = x + this.y = y + this.z = z + } +} + +class D2 { + val x: String + val y: String + val z: String + + constructor( + x: String, + y: String, + z: String, + ) { + this.x = x + this.y = y + this.z = z + } +} + +class A3 { + val x: String + + constructor(x: String) { + this.x = x + } +} + +class B3 { + val x: String + + constructor(x: String) { + this.x = x + } +} + +class C3 { + val x: String + + constructor( + x: String, + ) { + this.x = x + } +} + +class D3 { + val x: String + + constructor( + x: String, + ) { + this.x = x + } +} + +class E1 { + val x: String + val y: String + val z: String + + constructor( + x: String, + y: String, z: String, + ) { + this.x = x + this.y = y + this.z = z + } +} + +class E2 { + val x: String + val y: String + val z: String + + constructor( + x: String, + y: String, z: String) { + this.x = x + this.y = y + this.z = z + } +} + +class A1( + val x: String, + y: String, +) + +class B1( + val x: String, + val y: String +) + +class C1( + val x: String, + val y: String, +) + +class D1( + val x: String, + val y: String, +) + +class A2( + val x: String, + val y: String, + val z: String, +) + +class B2( + val x: String, + val y: String, + val z: String +) + +class C2( + val x: String, + val y: String, + val z: String, +) + +class D2( + val x: String, + val y: String, + val z: String, +) + +class A3( + val x: String, +) + +class B3( + val x: String +) + +class C3( + val x: String, +) + +class D3( + val x: String, +) + +class A4( + val x: String, + val y: String, + val z: String, +) + +class B4( + val x: String, + val y: String, + val z: String +) + +class C4( + val x: String, + val y: String, + val z: String, +) + +class D4( + val x: String, + val y: String, + val z: String, +) + +class E1( + val x: String, val y: String, + val z: String, +) + +class E2( + val x: String, val y: String, val z: String +) + +class C( + z: String, val v: Int, val x: Int = + 42, val y: Int = + 42 +) + +val foo1: (Int, Int) -> Int = fun( + x, + y, +): Int = 42 + +val foo2: (Int, Int) -> Int = fun( + x, + y +): Int { + return x + y +} + +val foo3: (Int, Int) -> Int = fun( + x, y, +): Int { + return x + y +} + +val foo4: (Int) -> Int = fun( + x, +): Int = 42 + +val foo5: (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 { + return x + y +} + +val foo9: (Int, Int, Int) -> Int = fun( + x, + y: Int, + z, +): Int = 42 + +val foo10: (Int, Int, Int) -> Int = fun( + x, + y: Int, + z: Int +): Int = 43 + +val foo10 = fun( + x: Int, + y: Int, + z: Int +): Int = 43 + +val foo11 = fun( + x: Int, + y: Int, + z: Int, +): Int = 43 + +val foo12 = fun( + x: Int, y: Int, z: Int, +): Int = 43 + +val foo13 = fun( + x: Int, y: Int, z: Int, +): Int = 43 + +val foo14 = fun( + x: Int, y: Int, z: Int, +): Int = 43 + +fun a1( + x: String, + y: String, +) = Unit + +fun b1( + x: String, + y: String +) = Unit + +fun c1( + x: String, + y: String, +) = Unit + +fun d1( + x: String, + y: String, +) = Unit + +fun a2( + x: String, + y: String, + z: String, +) = Unit + +fun b2( + x: String, + y: String, + z: String +) = Unit + +fun c2( + x: String, + y: String, + z: String, +) = Unit + +fun d2( + x: String, + y: String, + z: String, +) = Unit + +fun a3( + x: String, +) = Unit + +fun b3( + x: String +) = Unit + +fun c3( + x: String, +) = Unit + +fun d3( + x: String, +) = Unit + +fun a4( + x: String, + y: String, + z: String, +) = Unit + +fun b4( + x: String, + y: String, + z: String +) = Unit + +fun c4( + x: String, + y: String, + z: String, +) = Unit + +fun d4( + x: String, + y: String, + z: String, +) = Unit + +fun foo( + x: Int = + 42 +) { +} + +class C( + val x: Int = + 42 +) + +class G( + val x: String, val y: String + = "", /* */ val z: String +) + +class G( + val x: String, val y: String + = "" /* */, /* */ val z: String +) + +class H( + val x: String, /* + */ + val y: String, + val z: String, +) + +class J( + val x: String, val y: String, + val z: String, /* + */ +) + +class K( + val x: String, val y: String, + val z: String, +) + +class L( + val x: String, val y: String, val z: String // adwd +) + +// SET_TRUE: ALLOW_TRAILING_COMMA +// SET_INT: METHOD_PARAMETERS_WRAP = 1 diff --git a/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAsNeeded.call.after.kt b/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAsNeeded.call.after.kt new file mode 100644 index 00000000000..6d7936aa2ca --- /dev/null +++ b/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAsNeeded.call.after.kt @@ -0,0 +1,486 @@ +class A1 { + val x: String + val y: String + + constructor( + x: String, + y: String, + ) { + this.x = x + this.y = y + } +} + +class B1 { + val x: String + val y: String + + constructor( + x: String, + y: String, + ) { + this.x = x + this.y = y + } +} + +class C1 { + val x: String + val y: String + + constructor( + x: String, + y: String, + ) { + this.x = x + this.y = y + } +} + +class D1 { + val x: String + val y: String + + constructor( + x: String, + y: String, + ) { + this.x = x + this.y = y + } +} + +class A2 { + val x: String + val y: String + val z: String + + constructor( + x: String, + y: String, + z: String, + ) { + this.x = x + this.y = y + this.z = z + } +} + +class B2 { + val x: String + val y: String + val z: String + + constructor( + x: String, + y: String, + z: String, + ) { + this.x = x + this.y = y + this.z = z + } +} + +class C2 { + val x: String + val y: String + val z: String + + constructor( + x: String, + y: String, + z: String, + ) { + this.x = x + this.y = y + this.z = z + } +} + +class D2 { + val x: String + val y: String + val z: String + + constructor( + x: String, + y: String, + z: String, + ) { + this.x = x + this.y = y + this.z = z + } +} + +class A3 { + val x: String + + constructor(x: String) { + this.x = x + } +} + +class B3 { + val x: String + + constructor(x: String) { + this.x = x + } +} + +class C3 { + val x: String + + constructor( + x: String, + ) { + this.x = x + } +} + +class D3 { + val x: String + + constructor( + x: String, + ) { + this.x = x + } +} + +class E1 { + val x: String + val y: String + val z: String + + constructor( + x: String, + y: String, z: String, + ) { + this.x = x + this.y = y + this.z = z + } +} + +class E2 { + val x: String + val y: String + val z: String + + constructor( + x: String, + y: String, z: String, + ) { + this.x = x + this.y = y + this.z = z + } +} + +class A1( + val x: String, + y: String, +) + +class B1( + val x: String, + val y: String, +) + +class C1( + val x: String, + val y: String, +) + +class D1( + val x: String, + val y: String, +) + +class A2( + val x: String, + val y: String, + val z: String, +) + +class B2( + val x: String, + val y: String, + val z: String, +) + +class C2( + val x: String, + val y: String, + val z: String, +) + +class D2( + val x: String, + val y: String, + val z: String, +) + +class A3( + val x: String, +) + +class B3( + val x: String, +) + +class C3( + val x: String, +) + +class D3( + val x: String, +) + +class A4( + val x: String, + val y: String, + val z: String, +) + +class B4( + val x: String, + val y: String, + val z: String, +) + +class C4( + val x: String, + val y: String, + val z: String, +) + +class D4( + val x: String, + val y: String, + val z: String, +) + +class E1( + val x: String, val y: String, + val z: String, +) + +class E2( + val x: String, val y: String, val z: String, +) + +class C( + z: String, val v: Int, + val x: Int = + 42, + val y: Int = + 42, +) + +val foo1: (Int, Int) -> Int = fun( + x, + y, +): Int = 42 + +val foo2: (Int, Int) -> Int = fun( + x, + y, +): Int { + return x + y +} + +val foo3: (Int, Int) -> Int = fun( + x, y, +): Int { + return x + y +} + +val foo4: (Int) -> Int = fun( + x, +): Int = 42 + +val foo5: (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 { + return x + y +} + +val foo9: (Int, Int, Int) -> Int = fun( + x, + y: Int, + z, +): Int = 42 + +val foo10: (Int, Int, Int) -> Int = fun( + x, + y: Int, + z: Int, +): Int = 43 + +val foo10 = fun( + x: Int, + y: Int, + z: Int, +): Int = 43 + +val foo11 = fun( + x: Int, + y: Int, + z: Int, +): Int = 43 + +val foo12 = fun( + x: Int, y: Int, z: Int, +): Int = 43 + +val foo13 = fun( + x: Int, y: Int, z: Int, +): Int = 43 + +val foo14 = fun( + x: Int, y: Int, z: Int, +): Int = 43 + +fun a1( + x: String, + y: String, +) = Unit + +fun b1( + x: String, + y: String, +) = Unit + +fun c1( + x: String, + y: String, +) = Unit + +fun d1( + x: String, + y: String, +) = Unit + +fun a2( + x: String, + y: String, + z: String, +) = Unit + +fun b2( + x: String, + y: String, + z: String, +) = Unit + +fun c2( + x: String, + y: String, + z: String, +) = Unit + +fun d2( + x: String, + y: String, + z: String, +) = Unit + +fun a3( + x: String, +) = Unit + +fun b3( + x: String, +) = Unit + +fun c3( + x: String, +) = Unit + +fun d3( + x: String, +) = Unit + +fun a4( + x: String, + y: String, + z: String, +) = Unit + +fun b4( + x: String, + y: String, + z: String, +) = Unit + +fun c4( + x: String, + y: String, + z: String, +) = Unit + +fun d4( + x: String, + y: String, + z: String, +) = Unit + +fun foo( + x: Int = + 42, +) { +} + +class C( + val x: Int = + 42, +) + +class G( + val x: String, + val y: String + = "", /* */ + val z: String, +) + +class G( + val x: String, + val y: String + = "", /* */ /* */ + val z: String, +) + +class H( + val x: String, /* + */ + val y: String, + val z: String, +) + +class J( + val x: String, val y: String, + val z: String, /* + */ +) + +class K( + val x: String, val y: String, + val z: String, +) + +class L( + val x: String, val y: String, val z: String, // adwd +) + +// SET_TRUE: ALLOW_TRAILING_COMMA +// SET_INT: METHOD_PARAMETERS_WRAP = 1 diff --git a/idea/tests/org/jetbrains/kotlin/formatter/AbstractFormatterTest.java b/idea/tests/org/jetbrains/kotlin/formatter/AbstractFormatterTest.java index d7f5ff40ea4..498aed17135 100644 --- a/idea/tests/org/jetbrains/kotlin/formatter/AbstractFormatterTest.java +++ b/idea/tests/org/jetbrains/kotlin/formatter/AbstractFormatterTest.java @@ -14,6 +14,7 @@ import com.intellij.openapi.roots.LanguageLevelProjectExtension; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.registry.Registry; +import com.intellij.openapi.util.registry.RegistryValue; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiFile; @@ -116,19 +117,28 @@ public abstract class AbstractFormatterTest extends KotlinLightIdeaTestCase { } public void doTest(@NotNull String expectedFileNameWithExtension) throws Exception { - doTest(expectedFileNameWithExtension, false); + doTest(expectedFileNameWithExtension, false, false); } public void doTestInverted(@NotNull String expectedFileNameWithExtension) throws Exception { - doTest(expectedFileNameWithExtension, true); + doTest(expectedFileNameWithExtension, true, false); } - public void doTest(@NotNull String expectedFileNameWithExtension, boolean inverted) throws Exception { + public void doTestInvertedCallSite(@NotNull String expectedFileNameWithExtension) throws Exception { + doTest(expectedFileNameWithExtension, true, true); + } + + public void doTestCallSite(@NotNull String expectedFileNameWithExtension) throws Exception { + doTest(expectedFileNameWithExtension, false, true); + } + + public void doTest(@NotNull String expectedFileNameWithExtension, boolean inverted, boolean callSite) throws Exception { String testFileName = expectedFileNameWithExtension.substring(0, expectedFileNameWithExtension.indexOf(".")); String testFileExtension = expectedFileNameWithExtension.substring(expectedFileNameWithExtension.lastIndexOf(".")); String originalFileText = FileUtil.loadFile(new File(testFileName + testFileExtension), true); CodeStyleSettings codeStyleSettings = CodeStyle.getSettings(getProject_()); + RegistryValue registryValue = Registry.get("kotlin.formatter.allowTrailingCommaOnCallSite"); try { Integer rightMargin = InTextDirectivesUtils.getPrefixedInt(originalFileText, "// RIGHT_MARGIN: "); if (rightMargin != null) { @@ -148,10 +158,12 @@ public abstract class AbstractFormatterTest extends KotlinLightIdeaTestCase { configurator.configureInvertedSettings(); } + registryValue.setValue(callSite); doTextTest(originalFileText, new File(expectedFileNameWithExtension), testFileExtension); } finally { codeStyleSettings.clearCodeStyleSettings(); + registryValue.resetToDefault(); } } } diff --git a/idea/tests/org/jetbrains/kotlin/formatter/FormatterTestGenerated.java b/idea/tests/org/jetbrains/kotlin/formatter/FormatterTestGenerated.java index 86cf98f5fc0..f4ad9b3e750 100644 --- a/idea/tests/org/jetbrains/kotlin/formatter/FormatterTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/formatter/FormatterTestGenerated.java @@ -1386,6 +1386,184 @@ public class FormatterTestGenerated extends AbstractFormatterTest { } } + @TestMetadata("idea/testData/formatter/trailingComma") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FormatterCallSite extends AbstractFormatterTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestCallSite, this, testDataFilePath); + } + + public void testAllFilesPresentInFormatterCallSite() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/formatter/trailingComma"), Pattern.compile("^([^\\.]+)\\.call\\.after\\.kt.*$"), null, true); + } + + @TestMetadata("idea/testData/formatter/trailingComma/collectionLiteralExpression") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class CollectionLiteralExpression extends AbstractFormatterTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestCallSite, this, testDataFilePath); + } + + public void testAllFilesPresentInCollectionLiteralExpression() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/formatter/trailingComma/collectionLiteralExpression"), Pattern.compile("^([^\\.]+)\\.call\\.after\\.kt.*$"), null, true); + } + + @TestMetadata("CollectionLiteralInAnnotation.call.after.kt") + public void testCollectionLiteralInAnnotation() throws Exception { + runTest("idea/testData/formatter/trailingComma/collectionLiteralExpression/CollectionLiteralInAnnotation.call.after.kt"); + } + } + + @TestMetadata("idea/testData/formatter/trailingComma/destructionDeclaration") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DestructionDeclaration extends AbstractFormatterTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestCallSite, this, testDataFilePath); + } + + public void testAllFilesPresentInDestructionDeclaration() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/formatter/trailingComma/destructionDeclaration"), Pattern.compile("^([^\\.]+)\\.call\\.after\\.kt.*$"), null, true); + } + } + + @TestMetadata("idea/testData/formatter/trailingComma/enumEntry") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class EnumEntry extends AbstractFormatterTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestCallSite, this, testDataFilePath); + } + + public void testAllFilesPresentInEnumEntry() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/formatter/trailingComma/enumEntry"), Pattern.compile("^([^\\.]+)\\.call\\.after\\.kt.*$"), null, true); + } + } + + @TestMetadata("idea/testData/formatter/trailingComma/indices") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Indices extends AbstractFormatterTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestCallSite, this, testDataFilePath); + } + + public void testAllFilesPresentInIndices() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/formatter/trailingComma/indices"), Pattern.compile("^([^\\.]+)\\.call\\.after\\.kt.*$"), null, true); + } + + @TestMetadata("IndicesAccess.call.after.kt") + public void testIndicesAccess() throws Exception { + runTest("idea/testData/formatter/trailingComma/indices/IndicesAccess.call.after.kt"); + } + } + + @TestMetadata("idea/testData/formatter/trailingComma/lambdaParameters") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class LambdaParameters extends AbstractFormatterTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestCallSite, this, testDataFilePath); + } + + public void testAllFilesPresentInLambdaParameters() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/formatter/trailingComma/lambdaParameters"), Pattern.compile("^([^\\.]+)\\.call\\.after\\.kt.*$"), null, true); + } + + @TestMetadata("LambdaParameterList.call.after.kt") + public void testLambdaParameterList() throws Exception { + runTest("idea/testData/formatter/trailingComma/lambdaParameters/LambdaParameterList.call.after.kt"); + } + } + + @TestMetadata("idea/testData/formatter/trailingComma/typeArguments") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TypeArguments extends AbstractFormatterTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestCallSite, this, testDataFilePath); + } + + public void testAllFilesPresentInTypeArguments() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/formatter/trailingComma/typeArguments"), Pattern.compile("^([^\\.]+)\\.call\\.after\\.kt.*$"), null, true); + } + + @TestMetadata("TypeArgumentList.call.after.kt") + public void testTypeArgumentList() throws Exception { + runTest("idea/testData/formatter/trailingComma/typeArguments/TypeArgumentList.call.after.kt"); + } + } + + @TestMetadata("idea/testData/formatter/trailingComma/typeParameters") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TypeParameters extends AbstractFormatterTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestCallSite, this, testDataFilePath); + } + + public void testAllFilesPresentInTypeParameters() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/formatter/trailingComma/typeParameters"), Pattern.compile("^([^\\.]+)\\.call\\.after\\.kt.*$"), null, true); + } + + @TestMetadata("TypeParameterList.call.after.kt") + public void testTypeParameterList() throws Exception { + runTest("idea/testData/formatter/trailingComma/typeParameters/TypeParameterList.call.after.kt"); + } + } + + @TestMetadata("idea/testData/formatter/trailingComma/valueArguments") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ValueArguments extends AbstractFormatterTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestCallSite, this, testDataFilePath); + } + + public void testAllFilesPresentInValueArguments() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/formatter/trailingComma/valueArguments"), Pattern.compile("^([^\\.]+)\\.call\\.after\\.kt.*$"), null, true); + } + + @TestMetadata("ArgumentListWrapAsNeeded.call.after.kt") + public void testArgumentListWrapAsNeeded() throws Exception { + runTest("idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.call.after.kt"); + } + } + + @TestMetadata("idea/testData/formatter/trailingComma/valueParameters") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ValueParameters extends AbstractFormatterTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestCallSite, this, testDataFilePath); + } + + public void testAllFilesPresentInValueParameters() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/formatter/trailingComma/valueParameters"), Pattern.compile("^([^\\.]+)\\.call\\.after\\.kt.*$"), null, true); + } + + @TestMetadata("ParameterListWrapAsNeeded.call.after.kt") + public void testParameterListWrapAsNeeded() throws Exception { + runTest("idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAsNeeded.call.after.kt"); + } + } + + @TestMetadata("idea/testData/formatter/trailingComma/whenEntry") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class WhenEntry extends AbstractFormatterTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestCallSite, this, testDataFilePath); + } + + public void testAllFilesPresentInWhenEntry() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/formatter/trailingComma/whenEntry"), Pattern.compile("^([^\\.]+)\\.call\\.after\\.kt.*$"), null, true); + } + } + } + @TestMetadata("idea/testData/formatter") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -1983,4 +2161,182 @@ public class FormatterTestGenerated extends AbstractFormatterTest { } } } + + @TestMetadata("idea/testData/formatter/trailingComma") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FormatterInvertedCallSite extends AbstractFormatterTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestInvertedCallSite, this, testDataFilePath); + } + + public void testAllFilesPresentInFormatterInvertedCallSite() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/formatter/trailingComma"), Pattern.compile("^([^\\.]+)\\.call\\.after\\.inv\\.kt.*$"), null, true); + } + + @TestMetadata("idea/testData/formatter/trailingComma/collectionLiteralExpression") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class CollectionLiteralExpression extends AbstractFormatterTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestInvertedCallSite, this, testDataFilePath); + } + + public void testAllFilesPresentInCollectionLiteralExpression() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/formatter/trailingComma/collectionLiteralExpression"), Pattern.compile("^([^\\.]+)\\.call\\.after\\.inv\\.kt.*$"), null, true); + } + + @TestMetadata("CollectionLiteralInAnnotation.call.after.inv.kt") + public void testCollectionLiteralInAnnotation() throws Exception { + runTest("idea/testData/formatter/trailingComma/collectionLiteralExpression/CollectionLiteralInAnnotation.call.after.inv.kt"); + } + } + + @TestMetadata("idea/testData/formatter/trailingComma/destructionDeclaration") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class DestructionDeclaration extends AbstractFormatterTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestInvertedCallSite, this, testDataFilePath); + } + + public void testAllFilesPresentInDestructionDeclaration() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/formatter/trailingComma/destructionDeclaration"), Pattern.compile("^([^\\.]+)\\.call\\.after\\.inv\\.kt.*$"), null, true); + } + } + + @TestMetadata("idea/testData/formatter/trailingComma/enumEntry") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class EnumEntry extends AbstractFormatterTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestInvertedCallSite, this, testDataFilePath); + } + + public void testAllFilesPresentInEnumEntry() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/formatter/trailingComma/enumEntry"), Pattern.compile("^([^\\.]+)\\.call\\.after\\.inv\\.kt.*$"), null, true); + } + } + + @TestMetadata("idea/testData/formatter/trailingComma/indices") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Indices extends AbstractFormatterTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestInvertedCallSite, this, testDataFilePath); + } + + public void testAllFilesPresentInIndices() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/formatter/trailingComma/indices"), Pattern.compile("^([^\\.]+)\\.call\\.after\\.inv\\.kt.*$"), null, true); + } + + @TestMetadata("IndicesAccess.call.after.inv.kt") + public void testIndicesAccess() throws Exception { + runTest("idea/testData/formatter/trailingComma/indices/IndicesAccess.call.after.inv.kt"); + } + } + + @TestMetadata("idea/testData/formatter/trailingComma/lambdaParameters") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class LambdaParameters extends AbstractFormatterTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestInvertedCallSite, this, testDataFilePath); + } + + public void testAllFilesPresentInLambdaParameters() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/formatter/trailingComma/lambdaParameters"), Pattern.compile("^([^\\.]+)\\.call\\.after\\.inv\\.kt.*$"), null, true); + } + + @TestMetadata("LambdaParameterList.call.after.inv.kt") + public void testLambdaParameterList() throws Exception { + runTest("idea/testData/formatter/trailingComma/lambdaParameters/LambdaParameterList.call.after.inv.kt"); + } + } + + @TestMetadata("idea/testData/formatter/trailingComma/typeArguments") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TypeArguments extends AbstractFormatterTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestInvertedCallSite, this, testDataFilePath); + } + + public void testAllFilesPresentInTypeArguments() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/formatter/trailingComma/typeArguments"), Pattern.compile("^([^\\.]+)\\.call\\.after\\.inv\\.kt.*$"), null, true); + } + + @TestMetadata("TypeArgumentList.call.after.inv.kt") + public void testTypeArgumentList() throws Exception { + runTest("idea/testData/formatter/trailingComma/typeArguments/TypeArgumentList.call.after.inv.kt"); + } + } + + @TestMetadata("idea/testData/formatter/trailingComma/typeParameters") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TypeParameters extends AbstractFormatterTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestInvertedCallSite, this, testDataFilePath); + } + + public void testAllFilesPresentInTypeParameters() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/formatter/trailingComma/typeParameters"), Pattern.compile("^([^\\.]+)\\.call\\.after\\.inv\\.kt.*$"), null, true); + } + + @TestMetadata("TypeParameterList.call.after.inv.kt") + public void testTypeParameterList() throws Exception { + runTest("idea/testData/formatter/trailingComma/typeParameters/TypeParameterList.call.after.inv.kt"); + } + } + + @TestMetadata("idea/testData/formatter/trailingComma/valueArguments") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ValueArguments extends AbstractFormatterTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestInvertedCallSite, this, testDataFilePath); + } + + public void testAllFilesPresentInValueArguments() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/formatter/trailingComma/valueArguments"), Pattern.compile("^([^\\.]+)\\.call\\.after\\.inv\\.kt.*$"), null, true); + } + + @TestMetadata("ArgumentListWrapAsNeeded.call.after.inv.kt") + public void testArgumentListWrapAsNeeded() throws Exception { + runTest("idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.call.after.inv.kt"); + } + } + + @TestMetadata("idea/testData/formatter/trailingComma/valueParameters") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ValueParameters extends AbstractFormatterTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestInvertedCallSite, this, testDataFilePath); + } + + public void testAllFilesPresentInValueParameters() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/formatter/trailingComma/valueParameters"), Pattern.compile("^([^\\.]+)\\.call\\.after\\.inv\\.kt.*$"), null, true); + } + + @TestMetadata("ParameterListWrapAsNeeded.call.after.inv.kt") + public void testParameterListWrapAsNeeded() throws Exception { + runTest("idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAsNeeded.call.after.inv.kt"); + } + } + + @TestMetadata("idea/testData/formatter/trailingComma/whenEntry") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class WhenEntry extends AbstractFormatterTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestInvertedCallSite, this, testDataFilePath); + } + + public void testAllFilesPresentInWhenEntry() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/formatter/trailingComma/whenEntry"), Pattern.compile("^([^\\.]+)\\.call\\.after\\.inv\\.kt.*$"), null, true); + } + } + } } 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 f6071817a81..bf518ea02bd 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/smartEnter/SmartEnterTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/smartEnter/SmartEnterTest.kt @@ -1462,7 +1462,7 @@ class SmartEnterTest : KotlinLightCodeInsightFixtureTestCase() { """ fun foo(i: Int) = 1 fun test4() { - foo(1) + foo(1, ) } """ ) diff --git a/j2k/testData/fileOrElement/comments/fieldsInitializedFromParams.kt b/j2k/testData/fileOrElement/comments/fieldsInitializedFromParams.kt index 5941ce3034e..798f90772d8 100644 --- a/j2k/testData/fileOrElement/comments/fieldsInitializedFromParams.kt +++ b/j2k/testData/fileOrElement/comments/fieldsInitializedFromParams.kt @@ -1,9 +1,6 @@ -internal class C( - private val p1: Int /* parameter p1 */ // field p1 - , - /** - * Field myP2 - */ - private val myP2: Int, /* Field p3 */ - var p3: Int -) +internal class C(private val p1: Int /* parameter p1 */ // field p1 + , + /** + * Field myP2 + */ + private val myP2: Int, /* Field p3 */ var p3: Int) \ No newline at end of file diff --git a/nj2k/testData/newJ2k/methodCallExpression/stringMethods.kt b/nj2k/testData/newJ2k/methodCallExpression/stringMethods.kt index b2a0288b3c5..0f582d09d38 100644 --- a/nj2k/testData/newJ2k/methodCallExpression/stringMethods.kt +++ b/nj2k/testData/newJ2k/methodCallExpression/stringMethods.kt @@ -66,15 +66,13 @@ internal class A { val s = "test string" s == "test" s.equals( - "tesT" - , ignoreCase = true) + "tesT", ignoreCase = true) s.compareTo("Test", ignoreCase = true) s.regionMatches( 0, "TE", 0, - 2 - , ignoreCase = true) + 2, ignoreCase = true) s.regionMatches(0, "st", 1, 2) s.replace("\\w+".toRegex(), "---") .replaceFirst("([s-t])".toRegex(), "A$1")