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 be206a67187..47b186b6f7e 100644 --- a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt +++ b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt @@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.formatter import com.intellij.formatting.* import com.intellij.lang.ASTNode import com.intellij.openapi.util.TextRange +import com.intellij.openapi.util.text.StringUtil import com.intellij.psi.PsiComment import com.intellij.psi.PsiElement import com.intellij.psi.TokenType @@ -19,7 +20,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.getLineCount +import org.jetbrains.kotlin.idea.util.isMultiline import org.jetbrains.kotlin.idea.util.requireNode import org.jetbrains.kotlin.kdoc.lexer.KDocTokens import org.jetbrains.kotlin.kdoc.parser.KDocElementTypes @@ -585,29 +586,37 @@ abstract class KotlinCommonBlock( when { elementType === VALUE_ARGUMENT_LIST -> { val wrapSetting = commonSettings.CALL_PARAMETERS_WRAP - if ((wrapSetting == CommonCodeStyleSettings.WRAP_AS_NEEDED || wrapSetting == CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM) && + if (!node.withTrailingComma && (wrapSetting == CommonCodeStyleSettings.WRAP_AS_NEEDED || wrapSetting == CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM) && !needWrapArgumentList(nodePsi) ) { return ::noWrapping } - return getWrappingStrategyForItemList(wrapSetting, VALUE_ARGUMENT) + return getWrappingStrategyForItemList( + wrapSetting, + VALUE_ARGUMENT, + node.withTrailingComma, + additionalWrap = trailingCommaWrappingStrategy( + LPAR, + RPAR, + thisOrPrevIsMultiLineElement(VALUE_ARGUMENT, COMMA, LPAR, RPAR) + ) + ) } elementType === VALUE_PARAMETER_LIST -> { if (parentElementType === FUN || parentElementType === PRIMARY_CONSTRUCTOR || parentElementType === SECONDARY_CONSTRUCTOR - ) { - val wrap = Wrap.createWrap(commonSettings.METHOD_PARAMETERS_WRAP, false) - val withTrailingComma = node.withTrailingComma - return { childElement -> - val childElementType = childElement.elementType - if (withTrailingComma && (childElementType === RPAR || getPrevWithoutWhitespaceAndComments(childElement)?.elementType === LPAR)) - Wrap.createWrap(WrapType.ALWAYS, true) - else - wrap.takeIf { childElementType === VALUE_PARAMETER } - } - } + ) return getWrappingStrategyForItemList( + commonSettings.METHOD_PARAMETERS_WRAP, + VALUE_PARAMETER, + node.withTrailingComma, + additionalWrap = trailingCommaWrappingStrategy( + LPAR, + RPAR, + thisOrPrevIsMultiLineElement(VALUE_PARAMETER, COMMA, LPAR, RPAR) + ) + ) } elementType === SUPER_TYPE_LIST -> { @@ -710,9 +719,74 @@ abstract class KotlinCommonBlock( private val ASTNode.withTrailingComma: Boolean get() = when { lastChildNode?.let { getPrevWithoutWhitespaceAndComments(it) }?.elementType === COMMA -> true - settings.kotlinCustomSettings.ALLOW_TRAILING_COMMA -> psi?.getLineCount()?.let { it > 1 } == true + settings.kotlinCustomSettings.ALLOW_TRAILING_COMMA -> psi?.let(PsiElement::isMultiline) == true else -> false } + + private fun ASTNode.getSiblingNodeInSequence( + forward: Boolean, + withBreakElement: Boolean, + breakType: IElementType, + barrier: IElementType + ): ASTNode? { + var sibling: ASTNode? = null + for (element in siblings(forward).filter { it.elementType != WHITE_SPACE }.takeWhile { it.elementType != barrier }) { + if (withBreakElement) { + sibling = element + if (element.elementType == breakType) break + } else { + if (element.elementType == breakType) break + sibling = element + } + } + + return sibling + } + + private fun thisOrPrevIsMultiLineElement( + type: IElementType, + delimiterType: IElementType, + leftBarrier: IElementType, + rightBarrier: IElementType + ) = fun(childElement: ASTNode): Boolean { + if (childElement.elementType != type) return false + val psi = childElement.psi ?: return false + if (psi.isMultiline()) return true + + val startOffset = childElement.getSiblingNodeInSequence( + forward = false, + withBreakElement = true, + breakType = type, + barrier = leftBarrier + )?.startOffset ?: psi.startOffset + + val endOffset = childElement.getSiblingNodeInSequence( + forward = true, + withBreakElement = false, + breakType = delimiterType, + barrier = rightBarrier + )?.psi?.endOffset ?: psi.endOffset + + val treeParent = childElement.treeParent + val textRange = TextRange.create(startOffset, endOffset).shiftLeft(treeParent.startOffset) + return StringUtil.containsLineBreak(textRange.subSequence(treeParent.text)) + } + + private fun trailingCommaWrappingStrategy( + leftAnchor: IElementType, + rightAnchor: IElementType, + additionalCheck: (ASTNode) -> Boolean + ): WrappingStrategy = { childElement -> + val childElementType = childElement.elementType + if (childElement.treeParent.withTrailingComma && (childElementType === rightAnchor || + getPrevWithoutWhitespaceAndComments(childElement)?.elementType === leftAnchor || + additionalCheck(childElement) + ) + ) + Wrap.createWrap(WrapType.ALWAYS, true) + else + null + } } private fun ASTNode.isFirstParameter(): Boolean = treePrev?.elementType == LPAR @@ -1028,9 +1102,16 @@ private fun getPrevWithoutWhitespaceAndComments(pNode: ASTNode): ASTNode? { } } -private fun getWrappingStrategyForItemList(wrapType: Int, itemType: IElementType, wrapFirstElement: Boolean = false): WrappingStrategy { +private fun getWrappingStrategyForItemList( + wrapType: Int, + itemType: IElementType, + wrapFirstElement: Boolean = false, + additionalWrap: WrappingStrategy? = null +): WrappingStrategy { val itemWrap = Wrap.createWrap(wrapType, wrapFirstElement) - return { childElement -> if (childElement.elementType === itemType) itemWrap else null } + return { childElement -> + additionalWrap?.invoke(childElement) ?: if (childElement.elementType === itemType) itemWrap else null + } } private fun getWrappingStrategyForItemList(wrapType: Int, itemTypes: TokenSet, wrapFirstElement: Boolean = false): WrappingStrategy { diff --git a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt index 2ea040d7e67..4f1f9570daf 100644 --- a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt +++ b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt @@ -190,32 +190,34 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing ) } - inPosition(parent = VALUE_ARGUMENT_LIST, left = LPAR).customRule { parent, _, _ -> - if (kotlinCommonSettings.CALL_PARAMETERS_LPAREN_ON_NEXT_LINE && needWrapArgumentList(parent.requireNode().psi)) { - Spacing.createDependentLFSpacing( - 0, 0, - excludeLambdasAndObjects(parent), - commonCodeStyleSettings.KEEP_LINE_BREAKS, - commonCodeStyleSettings.KEEP_BLANK_LINES_IN_CODE - ) - } else { - createSpacing(0) - } - } - - inPosition(parent = VALUE_ARGUMENT_LIST, right = RPAR).customRule { parent, left, _ -> - when { - kotlinCommonSettings.CALL_PARAMETERS_RPAREN_ON_NEXT_LINE -> + if (!kotlinCustomSettings.ALLOW_TRAILING_COMMA) { + inPosition(parent = VALUE_ARGUMENT_LIST, left = LPAR).customRule { parent, _, _ -> + if (kotlinCommonSettings.CALL_PARAMETERS_LPAREN_ON_NEXT_LINE && needWrapArgumentList(parent.requireNode().psi)) { Spacing.createDependentLFSpacing( 0, 0, excludeLambdasAndObjects(parent), commonCodeStyleSettings.KEEP_LINE_BREAKS, commonCodeStyleSettings.KEEP_BLANK_LINES_IN_CODE ) - left.requireNode().elementType == COMMA -> // incomplete call being edited - createSpacing(1) - else -> + } else { createSpacing(0) + } + } + + inPosition(parent = VALUE_ARGUMENT_LIST, right = RPAR).customRule { parent, left, _ -> + when { + kotlinCommonSettings.CALL_PARAMETERS_RPAREN_ON_NEXT_LINE -> + Spacing.createDependentLFSpacing( + 0, 0, + excludeLambdasAndObjects(parent), + commonCodeStyleSettings.KEEP_LINE_BREAKS, + commonCodeStyleSettings.KEEP_BLANK_LINES_IN_CODE + ) + left.requireNode().elementType == COMMA -> // incomplete call being edited + createSpacing(1) + else -> + createSpacing(0) + } } } 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 ef50dab458e..2a0b5f757fa 100644 --- a/idea/formatter/src/org/jetbrains/kotlin/idea/util/FormatterUtil.kt +++ b/idea/formatter/src/org/jetbrains/kotlin/idea/util/FormatterUtil.kt @@ -36,4 +36,6 @@ fun PsiElement.getLineCount(): Int { } return StringUtil.getLineBreakCount(text ?: "") + 1 -} \ No newline at end of file +} + +fun PsiElement.isMultiline() = getLineCount() > 1 diff --git a/idea/src/org/jetbrains/kotlin/idea/formatter/TrailingCommaPostFormatProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/formatter/TrailingCommaPostFormatProcessor.kt index ba3cbf3786c..846fd18a542 100644 --- a/idea/src/org/jetbrains/kotlin/idea/formatter/TrailingCommaPostFormatProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/formatter/TrailingCommaPostFormatProcessor.kt @@ -10,16 +10,17 @@ import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.util.TextRange import com.intellij.psi.PsiElement import com.intellij.psi.PsiFile +import com.intellij.psi.codeStyle.CodeStyleManager import com.intellij.psi.codeStyle.CodeStyleSettings import com.intellij.psi.impl.source.codeStyle.PostFormatProcessor import com.intellij.psi.impl.source.codeStyle.PostFormatProcessorHelper -import org.jetbrains.kotlin.idea.util.getLineCount +import org.jetbrains.kotlin.idea.util.isMultiline import org.jetbrains.kotlin.lexer.KtTokens -import org.jetbrains.kotlin.psi.KtElement -import org.jetbrains.kotlin.psi.KtParameterList -import org.jetbrains.kotlin.psi.KtPsiFactory -import org.jetbrains.kotlin.psi.KtTreeVisitorVoid +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.createSmartPointer +import org.jetbrains.kotlin.psi.psiUtil.getPrevSiblingIgnoringWhitespace import org.jetbrains.kotlin.psi.psiUtil.getPrevSiblingIgnoringWhitespaceAndComments +import org.jetbrains.kotlin.psi.psiUtil.siblings import org.jetbrains.kotlin.utils.addToStdlib.safeAs class TrailingCommaPostFormatProcessor : PostFormatProcessor { @@ -37,6 +38,10 @@ private class TrailingCommaVisitor(val settings: CodeStyleSettings) : KtTreeVisi super.visitParameterList(list) } + override fun visitValueArgumentList(list: KtValueArgumentList) = processCommaOwnerIfInRange(list) { + super.visitValueArgumentList(list) + } + private fun processCommaOwnerIfInRange(element: KtElement, preHook: () -> Unit = {}) { if (myPostProcessor.isElementPartlyInRange(element)) { preHook() @@ -46,13 +51,47 @@ private class TrailingCommaVisitor(val settings: CodeStyleSettings) : KtTreeVisi private fun processCommaOwner(parent: KtElement) { val previous = parent.lastChild?.getPrevSiblingIgnoringWhitespaceAndComments() ?: return - if (previous.safeAs()?.elementType !== KtTokens.COMMA && - settings.kotlinCustomSettings.ALLOW_TRAILING_COMMA && - parent.getLineCount() > 1 - ) { - val oldLength = parent.textLength - parent.addAfter(KtPsiFactory(parent).createComma(), previous) - myPostProcessor.updateResultRange(oldLength, parent.textLength) + val elementType = previous.safeAs()?.elementType + if (elementType === KtTokens.COMMA || settings.kotlinCustomSettings.ALLOW_TRAILING_COMMA && parent.isMultiline()) { + // add a missing comma + if (elementType !== KtTokens.COMMA) { + changePsi(parent) { element, factory -> + element.addAfter(factory.createComma(), previous) + } + } + + correctCommaPosition(parent) + } + } + + private fun changePsi(element: KtElement, update: (KtElement, KtPsiFactory) -> Unit) { + val oldLength = element.textLength + update(element, KtPsiFactory(element)) + val result = CodeStyleManager.getInstance(element.project).reformat(element) + myPostProcessor.updateResultRange(oldLength, result.textLength) + } + + private fun correctCommaPosition(parent: KtElement) { + val lPar = parent.children.firstOrNull() ?: return + val rPar = parent.children.lastOrNull() ?: return + val invalidElements = lPar.siblings(withItself = false).takeWhile { it != rPar }.mapNotNull { + if (it !is ASTNode || it.elementType != KtTokens.COMMA) return@mapNotNull null + + val prevWithComment = it.getPrevSiblingIgnoringWhitespace(false) + val prevWithoutComment = it.getPrevSiblingIgnoringWhitespaceAndComments(false) + if (prevWithoutComment?.equals(prevWithComment) == false) { + it.createSmartPointer() to prevWithoutComment.createSmartPointer() + } else + null + }.toList() + + if (invalidElements.isNotEmpty()) { + changePsi(parent) { element, factory -> + for ((pointToComma, pointToElement) in invalidElements) { + element.addAfter(factory.createComma(), pointToElement.element) + pointToComma.element?.delete() + } + } } } diff --git a/idea/testData/formatter/ArrayLiteral.after.kt b/idea/testData/formatter/ArrayLiteral.after.kt index c38963642f2..a40d6e48f43 100644 --- a/idea/testData/formatter/ArrayLiteral.after.kt +++ b/idea/testData/formatter/ArrayLiteral.after.kt @@ -3,5 +3,5 @@ AppModule::class, DataModule::class, DomainModule::class - ] -) + ], +) \ No newline at end of file diff --git a/idea/testData/formatter/CallLParenthOnNextLine.after.inv.kt b/idea/testData/formatter/CallLParenthOnNextLine.after.inv.kt index e3ad0e44cc0..174743ae935 100644 --- a/idea/testData/formatter/CallLParenthOnNextLine.after.inv.kt +++ b/idea/testData/formatter/CallLParenthOnNextLine.after.inv.kt @@ -2,3 +2,4 @@ val x = foo("a", "b") // SET_TRUE: CALL_PARAMETERS_LPAREN_ON_NEXT_LINE +// TRAILING_COMMA: false \ No newline at end of file diff --git a/idea/testData/formatter/CallLParenthOnNextLine.after.kt b/idea/testData/formatter/CallLParenthOnNextLine.after.kt index c6ae06b5fcd..2b2438d5759 100644 --- a/idea/testData/formatter/CallLParenthOnNextLine.after.kt +++ b/idea/testData/formatter/CallLParenthOnNextLine.after.kt @@ -3,3 +3,4 @@ val x = foo( "b") // SET_TRUE: CALL_PARAMETERS_LPAREN_ON_NEXT_LINE +// TRAILING_COMMA: false \ No newline at end of file diff --git a/idea/testData/formatter/CallLParenthOnNextLine.kt b/idea/testData/formatter/CallLParenthOnNextLine.kt index e3ad0e44cc0..174743ae935 100644 --- a/idea/testData/formatter/CallLParenthOnNextLine.kt +++ b/idea/testData/formatter/CallLParenthOnNextLine.kt @@ -2,3 +2,4 @@ val x = foo("a", "b") // SET_TRUE: CALL_PARAMETERS_LPAREN_ON_NEXT_LINE +// TRAILING_COMMA: false \ No newline at end of file diff --git a/idea/testData/formatter/CallRParenthOnNextLine.after.inv.kt b/idea/testData/formatter/CallRParenthOnNextLine.after.inv.kt index 4ed30224beb..0729be26874 100644 --- a/idea/testData/formatter/CallRParenthOnNextLine.after.inv.kt +++ b/idea/testData/formatter/CallRParenthOnNextLine.after.inv.kt @@ -2,3 +2,4 @@ val x = foo("a", "b") // SET_TRUE: CALL_PARAMETERS_RPAREN_ON_NEXT_LINE +// TRAILING_COMMA: false \ No newline at end of file diff --git a/idea/testData/formatter/CallRParenthOnNextLine.after.kt b/idea/testData/formatter/CallRParenthOnNextLine.after.kt index c9be2f54526..47992087836 100644 --- a/idea/testData/formatter/CallRParenthOnNextLine.after.kt +++ b/idea/testData/formatter/CallRParenthOnNextLine.after.kt @@ -3,3 +3,4 @@ val x = foo("a", ) // SET_TRUE: CALL_PARAMETERS_RPAREN_ON_NEXT_LINE +// TRAILING_COMMA: false \ No newline at end of file diff --git a/idea/testData/formatter/CallRParenthOnNextLine.kt b/idea/testData/formatter/CallRParenthOnNextLine.kt index 4ed30224beb..0729be26874 100644 --- a/idea/testData/formatter/CallRParenthOnNextLine.kt +++ b/idea/testData/formatter/CallRParenthOnNextLine.kt @@ -2,3 +2,4 @@ val x = foo("a", "b") // SET_TRUE: CALL_PARAMETERS_RPAREN_ON_NEXT_LINE +// TRAILING_COMMA: false \ No newline at end of file diff --git a/idea/testData/formatter/CommentInFunctionLiteral.after.kt b/idea/testData/formatter/CommentInFunctionLiteral.after.kt index a86b5cd16a2..8dd75bc53a7 100644 --- a/idea/testData/formatter/CommentInFunctionLiteral.after.kt +++ b/idea/testData/formatter/CommentInFunctionLiteral.after.kt @@ -37,13 +37,17 @@ val s2 = Shadow { // wdwd val a = 42 } -val s3 = Shadow(fun() { // wdwd - val a = 42 -}) +val s3 = Shadow( + fun() { // wdwd + val a = 42 + }, +) -val s4 = Shadow(fun() { /* s */ - val a = 42 -}) +val s4 = Shadow( + fun() { /* s */ + val a = 42 + }, +) val s5 = Shadow { -> // wdwd @@ -55,15 +59,19 @@ val s6 = Shadow { val a = 42 } -val s7 = Shadow(fun() { - // wdwd - val a = 42 -}) +val s7 = Shadow( + fun() { + // wdwd + val a = 42 + }, +) -val s8 = Shadow(fun() { - // wdwd - val a = 42 -}) +val s8 = Shadow( + fun() { + // wdwd + val a = 42 + }, +) val s9 = Shadow { -> /* s */ val a = 42 diff --git a/idea/testData/formatter/ElvisIndent.after.inv.kt b/idea/testData/formatter/ElvisIndent.after.inv.kt index 5c7f185b052..9548a646720 100644 --- a/idea/testData/formatter/ElvisIndent.after.inv.kt +++ b/idea/testData/formatter/ElvisIndent.after.inv.kt @@ -4,7 +4,7 @@ fun foo() { ?: DescriptorUtils.getParentOfType( referencedDescriptor, TypeAliasConstructorDescriptor::class.java, - false + false, )?.typeAliasDescriptor ?: DescriptorUtils.getParentOfType(referencedDescriptor, FunctionDescriptor::class.java, false) ?: return emptyList() diff --git a/idea/testData/formatter/ElvisIndent.after.kt b/idea/testData/formatter/ElvisIndent.after.kt index eceec5730d8..8f0ea3ad0ec 100644 --- a/idea/testData/formatter/ElvisIndent.after.kt +++ b/idea/testData/formatter/ElvisIndent.after.kt @@ -4,7 +4,7 @@ fun foo() { ?: DescriptorUtils.getParentOfType( referencedDescriptor, TypeAliasConstructorDescriptor::class.java, - false + false, )?.typeAliasDescriptor ?: DescriptorUtils.getParentOfType(referencedDescriptor, FunctionDescriptor::class.java, false) ?: return emptyList() diff --git a/idea/testData/formatter/EnumInitializerList.after.kt b/idea/testData/formatter/EnumInitializerList.after.kt index 4b626eb6b89..62f4d1de4fb 100644 --- a/idea/testData/formatter/EnumInitializerList.after.kt +++ b/idea/testData/formatter/EnumInitializerList.after.kt @@ -3,6 +3,6 @@ package test enum class EnumTest(val value: Int) { VALUE_1 ( - value = 0 + value = 0, ) } \ No newline at end of file diff --git a/idea/testData/formatter/ExtendsListAlignEnum.after.inv.kt b/idea/testData/formatter/ExtendsListAlignEnum.after.inv.kt index 40f31a1ba3c..73d54fc6a71 100644 --- a/idea/testData/formatter/ExtendsListAlignEnum.after.inv.kt +++ b/idea/testData/formatter/ExtendsListAlignEnum.after.inv.kt @@ -2,7 +2,7 @@ enum class EnumTest(val value: Int) { VALUE_1( - value = 0 + value = 0, ) } diff --git a/idea/testData/formatter/ExtendsListAlignEnum.after.kt b/idea/testData/formatter/ExtendsListAlignEnum.after.kt index 40f31a1ba3c..73d54fc6a71 100644 --- a/idea/testData/formatter/ExtendsListAlignEnum.after.kt +++ b/idea/testData/formatter/ExtendsListAlignEnum.after.kt @@ -2,7 +2,7 @@ enum class EnumTest(val value: Int) { VALUE_1( - value = 0 + value = 0, ) } diff --git a/idea/testData/formatter/FunctionCallParametersAlign.after.kt b/idea/testData/formatter/FunctionCallParametersAlign.after.kt index 9d49208c08c..ed561a7e506 100644 --- a/idea/testData/formatter/FunctionCallParametersAlign.after.kt +++ b/idea/testData/formatter/FunctionCallParametersAlign.after.kt @@ -1,6 +1,8 @@ fun test() { - someTestLong(12, - 13) + someTestLong( + 12, + 13, + ) } // SET_TRUE: ALIGN_MULTILINE_PARAMETERS_IN_CALLS \ No newline at end of file diff --git a/idea/testData/formatter/FunctionExpression.after.kt b/idea/testData/formatter/FunctionExpression.after.kt index a70a38179eb..37dfeb35687 100644 --- a/idea/testData/formatter/FunctionExpression.after.kt +++ b/idea/testData/formatter/FunctionExpression.after.kt @@ -13,8 +13,10 @@ val c = fun() = 4 fun test() = fun test() = 4 fun test() { - test(fun() { - }) + test( + fun() { + }, + ) test(fun test() {}) test(fun test() = 5) diff --git a/idea/testData/formatter/ParameterAnnotationWrap.after.kt b/idea/testData/formatter/ParameterAnnotationWrap.after.kt index 2c46fe6ff52..894ff2a56b1 100644 --- a/idea/testData/formatter/ParameterAnnotationWrap.after.kt +++ b/idea/testData/formatter/ParameterAnnotationWrap.after.kt @@ -1,4 +1,5 @@ -fun foo(@Deprecated("x") +fun foo( + @Deprecated("x") x: Int, @Deprecated("y") @Deprecated("z") diff --git a/idea/testData/formatter/callChain/CallChainWrapping.after.inv.kt b/idea/testData/formatter/callChain/CallChainWrapping.after.inv.kt index a8b93704c9a..24bbdebb68a 100644 --- a/idea/testData/formatter/callChain/CallChainWrapping.after.inv.kt +++ b/idea/testData/formatter/callChain/CallChainWrapping.after.inv.kt @@ -41,10 +41,12 @@ val x8 = foo!!!!!!!! val x9 = ((b!!)!!!!)!! .f -val y = xyzzy(foo - .bar() - .baz() - .quux()) +val y = xyzzy( + foo + .bar() + .baz() + .quux(), +) fun foo() { foo diff --git a/idea/testData/formatter/callChain/CallChainWrapping.after.kt b/idea/testData/formatter/callChain/CallChainWrapping.after.kt index 3ea6ebc2aeb..bb2676463e6 100644 --- a/idea/testData/formatter/callChain/CallChainWrapping.after.kt +++ b/idea/testData/formatter/callChain/CallChainWrapping.after.kt @@ -30,9 +30,11 @@ 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.inv.kt b/idea/testData/formatter/callChain/FunctionLiteralsInChainCalls.after.inv.kt index 145b8864965..fbf91d499f5 100644 --- a/idea/testData/formatter/callChain/FunctionLiteralsInChainCalls.after.inv.kt +++ b/idea/testData/formatter/callChain/FunctionLiteralsInChainCalls.after.inv.kt @@ -12,12 +12,16 @@ fun test() { fun test1() { val abc = ArrayList() - .map({ - it * 2 - }) - .filter({ - it > 4 - }) + .map( + { + it * 2 + }, + ) + .filter( + { + it > 4 + }, + ) } fun test2() { @@ -35,7 +39,7 @@ fun test3() { fun test4() { val abc = ArrayList().mapTo( - LinkedHashSet() + LinkedHashSet(), ) { it * 2 } diff --git a/idea/testData/formatter/callChain/FunctionLiteralsInChainCalls.after.kt b/idea/testData/formatter/callChain/FunctionLiteralsInChainCalls.after.kt index 10c25ceabfe..cd977ff3bfe 100644 --- a/idea/testData/formatter/callChain/FunctionLiteralsInChainCalls.after.kt +++ b/idea/testData/formatter/callChain/FunctionLiteralsInChainCalls.after.kt @@ -12,12 +12,16 @@ fun test() { fun test1() { val abc = ArrayList() - .map({ - it * 2 - }) - .filter({ - it > 4 - }) + .map( + { + it * 2 + }, + ) + .filter( + { + it > 4 + }, + ) } fun test2() { @@ -35,7 +39,7 @@ fun test3() { fun test4() { val abc = ArrayList().mapTo( - LinkedHashSet() + LinkedHashSet(), ) { it * 2 } diff --git a/idea/testData/formatter/callChain/KT22148.after.kt b/idea/testData/formatter/callChain/KT22148.after.kt index d582ebcedba..9d5412bb768 100644 --- a/idea/testData/formatter/callChain/KT22148.after.kt +++ b/idea/testData/formatter/callChain/KT22148.after.kt @@ -6,9 +6,11 @@ fun foo() { finish() } - FirebaseAuth.getInstance().addAuthStateListener(object : FirebaseAuth.AuthStateListener { - override fun onAuthStateChanged(auth: FirebaseAuth) { - // ... - } - }) + FirebaseAuth.getInstance().addAuthStateListener( + object : FirebaseAuth.AuthStateListener { + override fun onAuthStateChanged(auth: FirebaseAuth) { + // ... + } + }, + ) } diff --git a/idea/testData/formatter/parameterList/ArgumentListChopAsNeeded.after.kt b/idea/testData/formatter/parameterList/ArgumentListChopAsNeeded.after.kt index 57213a05f53..352bcb4236d 100644 --- a/idea/testData/formatter/parameterList/ArgumentListChopAsNeeded.after.kt +++ b/idea/testData/formatter/parameterList/ArgumentListChopAsNeeded.after.kt @@ -10,12 +10,15 @@ fun foo() { testtest(foofoo) testtesttesttest( - foofoofoofoofoofoofoofoofoofoofoofoo) + foofoofoofoofoofoofoofoofoofoofoofoo, + ) testtest(foobar, barfoo) - testtesttesttest(foofoo, - barbar, - foobar, - barfoo) + testtesttesttest( + foofoo, + barbar, + foobar, + barfoo, + ) } \ No newline at end of file diff --git a/idea/testData/formatter/parameterList/ArgumentListWrapAlways.after.kt b/idea/testData/formatter/parameterList/ArgumentListWrapAlways.after.kt index 5d5a1d8d0c2..fb7f5c3cee5 100644 --- a/idea/testData/formatter/parameterList/ArgumentListWrapAlways.after.kt +++ b/idea/testData/formatter/parameterList/ArgumentListWrapAlways.after.kt @@ -11,11 +11,15 @@ fun foo() { testtesttesttest(foofoofoofoofoofoofoofoofoofoofoofoo) - testtest(foobar, - barfoo) + testtest( + foobar, + barfoo, + ) - testtesttesttest(foofoo, - barbar, - foobar, - barfoo) + testtesttesttest( + foofoo, + barbar, + foobar, + barfoo, + ) } \ No newline at end of file diff --git a/idea/testData/formatter/parameterList/ArgumentListWrapAsNeeded.after.kt b/idea/testData/formatter/parameterList/ArgumentListWrapAsNeeded.after.kt index 41dbfd09778..c4cbca089d8 100644 --- a/idea/testData/formatter/parameterList/ArgumentListWrapAsNeeded.after.kt +++ b/idea/testData/formatter/parameterList/ArgumentListWrapAsNeeded.after.kt @@ -10,12 +10,15 @@ fun foo() { testtest(foofoo) testtesttesttest( - foofoofoofoofoofoofoofoofoofoofoofoo) + foofoofoofoofoofoofoofoofoofoofoofoo, + ) testtest(foobar, barfoo) - testtesttesttest(foofoo, - barbar, - foobar, - barfoo) + testtesttesttest( + foofoo, + barbar, + foobar, + barfoo, + ) } \ No newline at end of file diff --git a/idea/testData/formatter/parameterList/ArgumentListWrapLParen.after.kt b/idea/testData/formatter/parameterList/ArgumentListWrapLParen.after.kt index 2b60cd24df6..d678249a11a 100644 --- a/idea/testData/formatter/parameterList/ArgumentListWrapLParen.after.kt +++ b/idea/testData/formatter/parameterList/ArgumentListWrapLParen.after.kt @@ -4,8 +4,10 @@ fun foo() { foo(bar, baz) - foo(object : Quux { - override fun foo() { - } - }) + foo( + object : Quux { + override fun foo() { + } + }, + ) } diff --git a/idea/testData/formatter/parameterList/KT19727.after.kt b/idea/testData/formatter/parameterList/KT19727.after.kt index 0b19e2465af..3ca1301f82b 100644 --- a/idea/testData/formatter/parameterList/KT19727.after.kt +++ b/idea/testData/formatter/parameterList/KT19727.after.kt @@ -5,19 +5,28 @@ fun useCallable(tag: String, callable: Callable<*>) { fun main(args: Array) { useCallable("A", Callable { println("Hello world") }) - useCallable("B", Callable { - println("Hello world") - }) + useCallable( + "B", + Callable { + println("Hello world") + }, + ) - useCallable("C", object : Callable { - override fun call() { - println("Hello world") - } - }) + useCallable( + "C", + object : Callable { + override fun call() { + println("Hello world") + } + }, + ) - useCallable("B", fun() { - println("Hello world") - }) + useCallable( + "B", + fun() { + println("Hello world") + }, + ) } // SET_TRUE: CALL_PARAMETERS_LPAREN_ON_NEXT_LINE diff --git a/idea/testData/formatter/parameterList/ParameterListChopAsNeeded.after.kt b/idea/testData/formatter/parameterList/ParameterListChopAsNeeded.after.kt index 4bed1eb61f2..ef42cb1456a 100644 --- a/idea/testData/formatter/parameterList/ParameterListChopAsNeeded.after.kt +++ b/idea/testData/formatter/parameterList/ParameterListChopAsNeeded.after.kt @@ -12,10 +12,11 @@ fun testtesttesttest(foofoo: Int) fun test(foo: Int, bar: Int) -fun testtesttesttest(foofoo: Int, - barbar: Int, - foobar: Int, - barfoo: Int, +fun testtesttesttest( + foofoo: Int, + barbar: Int, + foobar: Int, + barfoo: Int, ) fun test() { @@ -40,7 +41,8 @@ class LongLongLongLongNameCLass class ShorName class SN -class A(longLongLongLongNameCLass1: LongLongLongLongNameCLass, +class A( + longLongLongLongNameCLass1: LongLongLongLongNameCLass, longLongLongLongNameCLass2: LongLongLongLongNameCLass, longLongLongLongNameCLass3: LongLongLongLongNameCLass, ) { @@ -52,18 +54,21 @@ class A(longLongLongLongNameCLass1: LongLongLongLongNameCLass, } } -class B(a: LongLongLongLongNameCLass, +class B( + a: LongLongLongLongNameCLass, b: LongLongLongLongNameCLass, c: LongLongLongLongNameCLass, ) { - constructor(a: LongLongLongLongNameCLass, - b: LongLongLongLongNameCLass, - c: LongLongLongLongNameCLass, + constructor( + a: LongLongLongLongNameCLass, + b: LongLongLongLongNameCLass, + c: LongLongLongLongNameCLass, ) { } } -class C(sn1: ShorName, +class C( + sn1: ShorName, sn2: ShorName, sn3: ShorName, sn4: ShorName, @@ -73,20 +78,22 @@ class C(sn1: ShorName, sn8: ShorName, sn9: ShorName, ) { - constructor(sn1: ShorName, - sn2: ShorName, - sn3: ShorName, - sn4: ShorName, - sn5: ShorName, - sn6: ShorName, - sn6: ShorName, - sn8: ShorName, - sn9: ShorName, + constructor( + sn1: ShorName, + sn2: ShorName, + sn3: ShorName, + sn4: ShorName, + sn5: ShorName, + sn6: ShorName, + sn6: ShorName, + sn8: ShorName, + sn9: ShorName, ) { } } -class D(sn1: SN, +class D( + sn1: SN, sn2: SN, sn3: SN, sn4: SN, @@ -101,20 +108,21 @@ class D(sn1: SN, sn13: SN, sn14: SN, ) { - constructor(sn1: SN, - sn2: SN, - sn3: SN, - sn4: SN, - sn5: SN, - sn6: SN, - sn6: SN, - sn8: SN, - sn9: SN, - sn10: SN, - sn11: SN, - sn12: SN, - sn13: SN, - sn14: SN, + constructor( + sn1: SN, + sn2: SN, + sn3: SN, + sn4: SN, + sn5: SN, + sn6: SN, + sn6: SN, + sn8: SN, + sn9: SN, + sn10: SN, + sn11: SN, + sn12: SN, + sn13: SN, + sn14: SN, ) { } } diff --git a/idea/testData/formatter/parameterList/ParameterListWrapAlways.after.kt b/idea/testData/formatter/parameterList/ParameterListWrapAlways.after.kt index a132fcbb979..c8e7cdc278a 100644 --- a/idea/testData/formatter/parameterList/ParameterListWrapAlways.after.kt +++ b/idea/testData/formatter/parameterList/ParameterListWrapAlways.after.kt @@ -10,26 +10,30 @@ fun testtest(foofoo: Int) fun testtesttesttest(foofoo: Int) -fun test(foo: Int, - bar: Int, +fun test( + foo: Int, + bar: Int, ) -fun testtesttesttest(foofoo: Int, - barbar: Int, - foobar: Int, - barfoo: Int, +fun testtesttesttest( + foofoo: Int, + barbar: Int, + foobar: Int, + barfoo: Int, ) -fun testtesttesttest(foofoo: Int, - @Some barbar: Int, - foobar: Int, - barfoo: Int, +fun testtesttesttest( + foofoo: Int, + @Some barbar: Int, + foobar: Int, + barfoo: Int, ) -fun testtesttesttest(@Some foofoo: Int, - @Some barbar: Int, - @Some foobar: Int, - barfoo: Int, +fun testtesttesttest( + @Some foofoo: Int, + @Some barbar: Int, + @Some foobar: Int, + barfoo: Int, ) fun test() { @@ -54,29 +58,34 @@ class LongLongLongLongNameCLass class ShorName class SN -class A(longLongLongLongNameCLass1: LongLongLongLongNameCLass, +class A( + longLongLongLongNameCLass1: LongLongLongLongNameCLass, longLongLongLongNameCLass2: LongLongLongLongNameCLass, longLongLongLongNameCLass3: LongLongLongLongNameCLass, ) { - constructor(longLongLongLongNameCLass1: LongLongLongLongNameCLass, - longLongLongLongNameCLass2: LongLongLongLongNameCLass, - longLongLongLongNameCLass3: LongLongLongLongNameCLass, + constructor( + longLongLongLongNameCLass1: LongLongLongLongNameCLass, + longLongLongLongNameCLass2: LongLongLongLongNameCLass, + longLongLongLongNameCLass3: LongLongLongLongNameCLass, ) { } } -class B(a: LongLongLongLongNameCLass, +class B( + a: LongLongLongLongNameCLass, b: LongLongLongLongNameCLass, c: LongLongLongLongNameCLass, ) { - constructor(a: LongLongLongLongNameCLass, - b: LongLongLongLongNameCLass, - c: LongLongLongLongNameCLass, + constructor( + a: LongLongLongLongNameCLass, + b: LongLongLongLongNameCLass, + c: LongLongLongLongNameCLass, ) { } } -class C(sn1: ShorName, +class C( + sn1: ShorName, sn2: ShorName, sn3: ShorName, sn4: ShorName, @@ -86,20 +95,22 @@ class C(sn1: ShorName, sn8: ShorName, sn9: ShorName, ) { - constructor(sn1: ShorName, - sn2: ShorName, - sn3: ShorName, - sn4: ShorName, - sn5: ShorName, - sn6: ShorName, - sn6: ShorName, - sn8: ShorName, - sn9: ShorName, + constructor( + sn1: ShorName, + sn2: ShorName, + sn3: ShorName, + sn4: ShorName, + sn5: ShorName, + sn6: ShorName, + sn6: ShorName, + sn8: ShorName, + sn9: ShorName, ) { } } -class D(sn1: SN, +class D( + sn1: SN, sn2: SN, sn3: SN, sn4: SN, @@ -114,20 +125,21 @@ class D(sn1: SN, sn13: SN, sn14: SN, ) { - constructor(sn1: SN, - sn2: SN, - sn3: SN, - sn4: SN, - sn5: SN, - sn6: SN, - sn6: SN, - sn8: SN, - sn9: SN, - sn10: SN, - sn11: SN, - sn12: SN, - sn13: SN, - sn14: SN, + constructor( + sn1: SN, + sn2: SN, + sn3: SN, + sn4: SN, + sn5: SN, + sn6: SN, + sn6: SN, + sn8: SN, + sn9: SN, + sn10: SN, + sn11: SN, + sn12: SN, + sn13: SN, + sn14: SN, ) { } } @@ -147,14 +159,16 @@ class G(sn1: ShorName) { } } -class H(sn1: SN, +class H( + sn1: SN, sn2: SN, ) { constructor(sn1: SN) { } } -class I(sn1: SN, +class I( + sn1: SN, @field:Some val sn2: SN, sn3: SN, sn4: SN, @@ -169,20 +183,21 @@ class I(sn1: SN, sn13: SN, sn14: SN, ) { - constructor(sn1: SN, - sn2: SN, - sn3: SN, - @Some sn4: SN, - sn5: SN, - sn6: SN, - sn6: SN, - sn8: SN, - sn9: SN, - sn10: SN, - sn11: SN, - sn12: SN, - sn13: SN, - sn14: SN, + constructor( + sn1: SN, + sn2: SN, + sn3: SN, + @Some sn4: SN, + sn5: SN, + sn6: SN, + sn6: SN, + sn8: SN, + sn9: SN, + sn10: SN, + sn11: SN, + sn12: SN, + sn13: SN, + sn14: SN, ) { } } diff --git a/idea/testData/formatter/parameterList/ParameterListWrapAsNeeded.after.kt b/idea/testData/formatter/parameterList/ParameterListWrapAsNeeded.after.kt index 8124c26daa6..d9720e2dad2 100644 --- a/idea/testData/formatter/parameterList/ParameterListWrapAsNeeded.after.kt +++ b/idea/testData/formatter/parameterList/ParameterListWrapAsNeeded.after.kt @@ -43,7 +43,8 @@ class LongLongLongLongNameCLass class ShorName class SN -class A(longLongLongLongNameCLass1: LongLongLongLongNameCLass, +class A( + longLongLongLongNameCLass1: LongLongLongLongNameCLass, longLongLongLongNameCLass2: LongLongLongLongNameCLass, longLongLongLongNameCLass3: LongLongLongLongNameCLass, ) { @@ -55,7 +56,8 @@ class A(longLongLongLongNameCLass1: LongLongLongLongNameCLass, } } -class B(a: LongLongLongLongNameCLass, +class B( + a: LongLongLongLongNameCLass, b: LongLongLongLongNameCLass, c: LongLongLongLongNameCLass, ) { @@ -67,7 +69,8 @@ class B(a: LongLongLongLongNameCLass, } } -class C(sn1: ShorName, +class C( + sn1: ShorName, sn2: ShorName, sn3: ShorName, sn4: ShorName, @@ -77,20 +80,22 @@ class C(sn1: ShorName, sn8: ShorName, sn9: ShorName, ) { - constructor(sn1: ShorName, - sn2: ShorName, - sn3: ShorName, - sn4: ShorName, - sn5: ShorName, - sn6: ShorName, - sn6: ShorName, - sn8: ShorName, - sn9: ShorName, + constructor( + sn1: ShorName, + sn2: ShorName, + sn3: ShorName, + sn4: ShorName, + sn5: ShorName, + sn6: ShorName, + sn6: ShorName, + sn8: ShorName, + sn9: ShorName, ) { } } -class D(sn1: SN, sn2: SN, +class D( + sn1: SN, sn2: SN, sn3: SN, sn4: SN, sn5: SN, sn6: SN, sn6: SN, sn8: SN, @@ -98,20 +103,21 @@ class D(sn1: SN, sn2: SN, sn11: SN, sn12: SN, sn13: SN, sn14: SN, ) { - constructor(sn1: SN, - sn2: SN, - sn3: SN, - sn4: SN, - sn5: SN, - sn6: SN, - sn6: SN, - sn8: SN, - sn9: SN, - sn10: SN, - sn11: SN, - sn12: SN, - sn13: SN, - sn14: SN, + constructor( + sn1: SN, + sn2: SN, + sn3: SN, + sn4: SN, + sn5: SN, + sn6: SN, + sn6: SN, + sn8: SN, + sn9: SN, + sn10: SN, + sn11: SN, + sn12: SN, + sn13: SN, + sn14: SN, ) { } } diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.after.inv.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.after.inv.kt new file mode 100644 index 00000000000..2c15f0a2854 --- /dev/null +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.after.inv.kt @@ -0,0 +1,278 @@ +// SET_INT: CALL_PARAMETERS_WRAP = 4 +// 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 + ) +} \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.after.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.after.kt new file mode 100644 index 00000000000..ba02979d506 --- /dev/null +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.after.kt @@ -0,0 +1,367 @@ +// SET_INT: CALL_PARAMETERS_WRAP = 4 +// 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 + ) +} \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.kt new file mode 100644 index 00000000000..817aab799c3 --- /dev/null +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.kt @@ -0,0 +1,200 @@ +// SET_INT: CALL_PARAMETERS_WRAP = 4 +// 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 + ) +} \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.after.inv.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.after.inv.kt new file mode 100644 index 00000000000..6bb5b656bba --- /dev/null +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.after.inv.kt @@ -0,0 +1,261 @@ +// SET_INT: CALL_PARAMETERS_WRAP = 0 +// 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 + ) +} \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.after.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.after.kt new file mode 100644 index 00000000000..c6ebace8056 --- /dev/null +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.after.kt @@ -0,0 +1,364 @@ +// SET_INT: CALL_PARAMETERS_WRAP = 0 +// 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 + ) +} \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.kt new file mode 100644 index 00000000000..0fcd7e966f3 --- /dev/null +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.kt @@ -0,0 +1,200 @@ +// SET_INT: CALL_PARAMETERS_WRAP = 0 +// 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 + ) +} \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.after.inv.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.after.inv.kt new file mode 100644 index 00000000000..564965bf42a --- /dev/null +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.after.inv.kt @@ -0,0 +1,348 @@ +// SET_INT: CALL_PARAMETERS_WRAP = 2 +// 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( + 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 + ) +} \ 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 new file mode 100644 index 00000000000..a927519e569 --- /dev/null +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.after.kt @@ -0,0 +1,429 @@ +// SET_INT: CALL_PARAMETERS_WRAP = 2 +// 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( + 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 + ) +} \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.kt new file mode 100644 index 00000000000..41f911654eb --- /dev/null +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.kt @@ -0,0 +1,208 @@ +// SET_INT: CALL_PARAMETERS_WRAP = 2 +// 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(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 + ) +} \ 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 new file mode 100644 index 00000000000..d1e53a1bcd1 --- /dev/null +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.after.inv.kt @@ -0,0 +1,261 @@ +// 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 + ) +} \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.after.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.after.kt new file mode 100644 index 00000000000..0c3dc1bb67a --- /dev/null +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.after.kt @@ -0,0 +1,364 @@ +// 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 + ) +} \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.kt b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.kt new file mode 100644 index 00000000000..978e583dbf8 --- /dev/null +++ b/idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.kt @@ -0,0 +1,200 @@ +// 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 + ) +} \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueParameters/Function.after.inv.kt b/idea/testData/formatter/trailingComma/valueParameters/Function.after.inv.kt deleted file mode 100644 index a4f67211ac8..00000000000 --- a/idea/testData/formatter/trailingComma/valueParameters/Function.after.inv.kt +++ /dev/null @@ -1,85 +0,0 @@ -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 - -// SET_TRUE: ALLOW_TRAILING_COMMA \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueParameters/Function.after.kt b/idea/testData/formatter/trailingComma/valueParameters/Function.after.kt deleted file mode 100644 index f1e58ea65cd..00000000000 --- a/idea/testData/formatter/trailingComma/valueParameters/Function.after.kt +++ /dev/null @@ -1,85 +0,0 @@ -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 - -// SET_TRUE: ALLOW_TRAILING_COMMA \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueParameters/Function.kt b/idea/testData/formatter/trailingComma/valueParameters/Function.kt deleted file mode 100644 index 839cffeda09..00000000000 --- a/idea/testData/formatter/trailingComma/valueParameters/Function.kt +++ /dev/null @@ -1,81 +0,0 @@ -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 - -// SET_TRUE: ALLOW_TRAILING_COMMA \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueParameters/OptionalTypes.after.inv.kt b/idea/testData/formatter/trailingComma/valueParameters/OptionalTypes.after.inv.kt deleted file mode 100644 index f3f577e0628..00000000000 --- a/idea/testData/formatter/trailingComma/valueParameters/OptionalTypes.after.inv.kt +++ /dev/null @@ -1,75 +0,0 @@ -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 - -// SET_TRUE: ALLOW_TRAILING_COMMA \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueParameters/OptionalTypes.after.kt b/idea/testData/formatter/trailingComma/valueParameters/OptionalTypes.after.kt deleted file mode 100644 index e581494c562..00000000000 --- a/idea/testData/formatter/trailingComma/valueParameters/OptionalTypes.after.kt +++ /dev/null @@ -1,75 +0,0 @@ -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 - -// SET_TRUE: ALLOW_TRAILING_COMMA \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueParameters/OptionalTypes.kt b/idea/testData/formatter/trailingComma/valueParameters/OptionalTypes.kt deleted file mode 100644 index 3169be915e9..00000000000 --- a/idea/testData/formatter/trailingComma/valueParameters/OptionalTypes.kt +++ /dev/null @@ -1,69 +0,0 @@ -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 - -// SET_TRUE: ALLOW_TRAILING_COMMA \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueParameters/ParameterListChopAsNeeded.after.inv.kt b/idea/testData/formatter/trailingComma/valueParameters/ParameterListChopAsNeeded.after.inv.kt new file mode 100644 index 00000000000..ae00476af1c --- /dev/null +++ b/idea/testData/formatter/trailingComma/valueParameters/ParameterListChopAsNeeded.after.inv.kt @@ -0,0 +1,485 @@ +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 +) + +// SET_TRUE: ALLOW_TRAILING_COMMA +// SET_INT: METHOD_PARAMETERS_WRAP = 4 diff --git a/idea/testData/formatter/trailingComma/valueParameters/ParameterListChopAsNeeded.after.kt b/idea/testData/formatter/trailingComma/valueParameters/ParameterListChopAsNeeded.after.kt new file mode 100644 index 00000000000..e938f31674d --- /dev/null +++ b/idea/testData/formatter/trailingComma/valueParameters/ParameterListChopAsNeeded.after.kt @@ -0,0 +1,492 @@ +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, +) + +// SET_TRUE: ALLOW_TRAILING_COMMA +// SET_INT: METHOD_PARAMETERS_WRAP = 4 diff --git a/idea/testData/formatter/trailingComma/valueParameters/ParameterListChopAsNeeded.kt b/idea/testData/formatter/trailingComma/valueParameters/ParameterListChopAsNeeded.kt new file mode 100644 index 00000000000..fa69907a190 --- /dev/null +++ b/idea/testData/formatter/trailingComma/valueParameters/ParameterListChopAsNeeded.kt @@ -0,0 +1,461 @@ +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 +) + +// SET_TRUE: ALLOW_TRAILING_COMMA +// SET_INT: METHOD_PARAMETERS_WRAP = 4 diff --git a/idea/testData/formatter/trailingComma/valueParameters/ParameterListDoNotWrap.after.inv.kt b/idea/testData/formatter/trailingComma/valueParameters/ParameterListDoNotWrap.after.inv.kt new file mode 100644 index 00000000000..d2f643ed375 --- /dev/null +++ b/idea/testData/formatter/trailingComma/valueParameters/ParameterListDoNotWrap.after.inv.kt @@ -0,0 +1,485 @@ +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 +) + +// SET_TRUE: ALLOW_TRAILING_COMMA +// SET_INT: METHOD_PARAMETERS_WRAP = 0 diff --git a/idea/testData/formatter/trailingComma/valueParameters/ParameterListDoNotWrap.after.kt b/idea/testData/formatter/trailingComma/valueParameters/ParameterListDoNotWrap.after.kt new file mode 100644 index 00000000000..bf34d15be63 --- /dev/null +++ b/idea/testData/formatter/trailingComma/valueParameters/ParameterListDoNotWrap.after.kt @@ -0,0 +1,492 @@ +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, +) + +// SET_TRUE: ALLOW_TRAILING_COMMA +// SET_INT: METHOD_PARAMETERS_WRAP = 0 diff --git a/idea/testData/formatter/trailingComma/valueParameters/ParameterListDoNotWrap.kt b/idea/testData/formatter/trailingComma/valueParameters/ParameterListDoNotWrap.kt new file mode 100644 index 00000000000..bd40aeec435 --- /dev/null +++ b/idea/testData/formatter/trailingComma/valueParameters/ParameterListDoNotWrap.kt @@ -0,0 +1,461 @@ +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 +) + +// SET_TRUE: ALLOW_TRAILING_COMMA +// SET_INT: METHOD_PARAMETERS_WRAP = 0 diff --git a/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAlways.after.inv.kt b/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAlways.after.inv.kt new file mode 100644 index 00000000000..70228165705 --- /dev/null +++ b/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAlways.after.inv.kt @@ -0,0 +1,510 @@ +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 +) + +// SET_TRUE: ALLOW_TRAILING_COMMA +// SET_INT: METHOD_PARAMETERS_WRAP = 2 diff --git a/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAlways.after.kt b/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAlways.after.kt new file mode 100644 index 00000000000..e8064eb9e0e --- /dev/null +++ b/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAlways.after.kt @@ -0,0 +1,511 @@ +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, +) + +// SET_TRUE: ALLOW_TRAILING_COMMA +// SET_INT: METHOD_PARAMETERS_WRAP = 2 diff --git a/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAlways.kt b/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAlways.kt new file mode 100644 index 00000000000..9a0160249b3 --- /dev/null +++ b/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAlways.kt @@ -0,0 +1,461 @@ +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 +) + +// SET_TRUE: ALLOW_TRAILING_COMMA +// SET_INT: METHOD_PARAMETERS_WRAP = 2 diff --git a/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAsNeeded.after.inv.kt b/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAsNeeded.after.inv.kt new file mode 100644 index 00000000000..56e5ac3baf8 --- /dev/null +++ b/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAsNeeded.after.inv.kt @@ -0,0 +1,485 @@ +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 +) + +// SET_TRUE: ALLOW_TRAILING_COMMA +// SET_INT: METHOD_PARAMETERS_WRAP = 1 diff --git a/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAsNeeded.after.kt b/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAsNeeded.after.kt new file mode 100644 index 00000000000..492dae389a4 --- /dev/null +++ b/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAsNeeded.after.kt @@ -0,0 +1,492 @@ +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, +) + +// SET_TRUE: ALLOW_TRAILING_COMMA +// SET_INT: METHOD_PARAMETERS_WRAP = 1 diff --git a/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAsNeeded.kt b/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAsNeeded.kt new file mode 100644 index 00000000000..da1b798d385 --- /dev/null +++ b/idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAsNeeded.kt @@ -0,0 +1,461 @@ +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 +) + +// SET_TRUE: ALLOW_TRAILING_COMMA +// SET_INT: METHOD_PARAMETERS_WRAP = 1 diff --git a/idea/testData/formatter/trailingComma/valueParameters/PrimaryConstructor.after.inv.kt b/idea/testData/formatter/trailingComma/valueParameters/PrimaryConstructor.after.inv.kt deleted file mode 100644 index d0c85606d0b..00000000000 --- a/idea/testData/formatter/trailingComma/valueParameters/PrimaryConstructor.after.inv.kt +++ /dev/null @@ -1,94 +0,0 @@ -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 -) - -// SET_TRUE: ALLOW_TRAILING_COMMA \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueParameters/PrimaryConstructor.after.kt b/idea/testData/formatter/trailingComma/valueParameters/PrimaryConstructor.after.kt deleted file mode 100644 index 9332404b41b..00000000000 --- a/idea/testData/formatter/trailingComma/valueParameters/PrimaryConstructor.after.kt +++ /dev/null @@ -1,94 +0,0 @@ -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, -) - -// SET_TRUE: ALLOW_TRAILING_COMMA \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueParameters/PrimaryConstructor.kt b/idea/testData/formatter/trailingComma/valueParameters/PrimaryConstructor.kt deleted file mode 100644 index 0b48f37a610..00000000000 --- a/idea/testData/formatter/trailingComma/valueParameters/PrimaryConstructor.kt +++ /dev/null @@ -1,90 +0,0 @@ -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 -) - -// SET_TRUE: ALLOW_TRAILING_COMMA \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueParameters/SecondConstructor.after.inv.kt b/idea/testData/formatter/trailingComma/valueParameters/SecondConstructor.after.inv.kt deleted file mode 100644 index 0f4d61ea74a..00000000000 --- a/idea/testData/formatter/trailingComma/valueParameters/SecondConstructor.after.inv.kt +++ /dev/null @@ -1,184 +0,0 @@ -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 - } -} - -// SET_TRUE: ALLOW_TRAILING_COMMA \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueParameters/SecondConstructor.after.kt b/idea/testData/formatter/trailingComma/valueParameters/SecondConstructor.after.kt deleted file mode 100644 index 869494dcbcc..00000000000 --- a/idea/testData/formatter/trailingComma/valueParameters/SecondConstructor.after.kt +++ /dev/null @@ -1,185 +0,0 @@ -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 - } -} - -// SET_TRUE: ALLOW_TRAILING_COMMA \ No newline at end of file diff --git a/idea/testData/formatter/trailingComma/valueParameters/SecondConstructor.kt b/idea/testData/formatter/trailingComma/valueParameters/SecondConstructor.kt deleted file mode 100644 index 08502f225cb..00000000000 --- a/idea/testData/formatter/trailingComma/valueParameters/SecondConstructor.kt +++ /dev/null @@ -1,178 +0,0 @@ -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 - } -} - -// SET_TRUE: ALLOW_TRAILING_COMMA \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/formatter/FormatterTestGenerated.java b/idea/tests/org/jetbrains/kotlin/formatter/FormatterTestGenerated.java index b001edfa1f0..d1ac74a4ba2 100644 --- a/idea/tests/org/jetbrains/kotlin/formatter/FormatterTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/formatter/FormatterTestGenerated.java @@ -1164,6 +1164,39 @@ public class FormatterTestGenerated extends AbstractFormatterTest { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/formatter/trailingComma"), Pattern.compile("^([^\\.]+)\\.after\\.kt.*$"), null, true); } + @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::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInValueArguments() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/formatter/trailingComma/valueArguments"), Pattern.compile("^([^\\.]+)\\.after\\.kt.*$"), null, true); + } + + @TestMetadata("ArgumentListChopAsNeeded.after.kt") + public void testArgumentListChopAsNeeded() throws Exception { + runTest("idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.after.kt"); + } + + @TestMetadata("ArgumentListDoNotWrap.after.kt") + public void testArgumentListDoNotWrap() throws Exception { + runTest("idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.after.kt"); + } + + @TestMetadata("ArgumentListWrapAlways.after.kt") + public void testArgumentListWrapAlways() throws Exception { + runTest("idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.after.kt"); + } + + @TestMetadata("ArgumentListWrapAsNeeded.after.kt") + public void testArgumentListWrapAsNeeded() throws Exception { + runTest("idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.after.kt"); + } + } + @TestMetadata("idea/testData/formatter/trailingComma/valueParameters") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -1176,24 +1209,24 @@ public class FormatterTestGenerated extends AbstractFormatterTest { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/formatter/trailingComma/valueParameters"), Pattern.compile("^([^\\.]+)\\.after\\.kt.*$"), null, true); } - @TestMetadata("Function.after.kt") - public void testFunction() throws Exception { - runTest("idea/testData/formatter/trailingComma/valueParameters/Function.after.kt"); + @TestMetadata("ParameterListChopAsNeeded.after.kt") + public void testParameterListChopAsNeeded() throws Exception { + runTest("idea/testData/formatter/trailingComma/valueParameters/ParameterListChopAsNeeded.after.kt"); } - @TestMetadata("OptionalTypes.after.kt") - public void testOptionalTypes() throws Exception { - runTest("idea/testData/formatter/trailingComma/valueParameters/OptionalTypes.after.kt"); + @TestMetadata("ParameterListDoNotWrap.after.kt") + public void testParameterListDoNotWrap() throws Exception { + runTest("idea/testData/formatter/trailingComma/valueParameters/ParameterListDoNotWrap.after.kt"); } - @TestMetadata("PrimaryConstructor.after.kt") - public void testPrimaryConstructor() throws Exception { - runTest("idea/testData/formatter/trailingComma/valueParameters/PrimaryConstructor.after.kt"); + @TestMetadata("ParameterListWrapAlways.after.kt") + public void testParameterListWrapAlways() throws Exception { + runTest("idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAlways.after.kt"); } - @TestMetadata("SecondConstructor.after.kt") - public void testSecondConstructor() throws Exception { - runTest("idea/testData/formatter/trailingComma/valueParameters/SecondConstructor.after.kt"); + @TestMetadata("ParameterListWrapAsNeeded.after.kt") + public void testParameterListWrapAsNeeded() throws Exception { + runTest("idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAsNeeded.after.kt"); } } } @@ -1575,6 +1608,39 @@ public class FormatterTestGenerated extends AbstractFormatterTest { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/formatter/trailingComma"), Pattern.compile("^([^\\.]+)\\.after\\.inv\\.kt.*$"), null, true); } + @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::doTestInverted, this, testDataFilePath); + } + + public void testAllFilesPresentInValueArguments() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/formatter/trailingComma/valueArguments"), Pattern.compile("^([^\\.]+)\\.after\\.inv\\.kt.*$"), null, true); + } + + @TestMetadata("ArgumentListChopAsNeeded.after.inv.kt") + public void testArgumentListChopAsNeeded() throws Exception { + runTest("idea/testData/formatter/trailingComma/valueArguments/ArgumentListChopAsNeeded.after.inv.kt"); + } + + @TestMetadata("ArgumentListDoNotWrap.after.inv.kt") + public void testArgumentListDoNotWrap() throws Exception { + runTest("idea/testData/formatter/trailingComma/valueArguments/ArgumentListDoNotWrap.after.inv.kt"); + } + + @TestMetadata("ArgumentListWrapAlways.after.inv.kt") + public void testArgumentListWrapAlways() throws Exception { + runTest("idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAlways.after.inv.kt"); + } + + @TestMetadata("ArgumentListWrapAsNeeded.after.inv.kt") + public void testArgumentListWrapAsNeeded() throws Exception { + runTest("idea/testData/formatter/trailingComma/valueArguments/ArgumentListWrapAsNeeded.after.inv.kt"); + } + } + @TestMetadata("idea/testData/formatter/trailingComma/valueParameters") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -1587,24 +1653,24 @@ public class FormatterTestGenerated extends AbstractFormatterTest { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/formatter/trailingComma/valueParameters"), Pattern.compile("^([^\\.]+)\\.after\\.inv\\.kt.*$"), null, true); } - @TestMetadata("Function.after.inv.kt") - public void testFunction() throws Exception { - runTest("idea/testData/formatter/trailingComma/valueParameters/Function.after.inv.kt"); + @TestMetadata("ParameterListChopAsNeeded.after.inv.kt") + public void testParameterListChopAsNeeded() throws Exception { + runTest("idea/testData/formatter/trailingComma/valueParameters/ParameterListChopAsNeeded.after.inv.kt"); } - @TestMetadata("OptionalTypes.after.inv.kt") - public void testOptionalTypes() throws Exception { - runTest("idea/testData/formatter/trailingComma/valueParameters/OptionalTypes.after.inv.kt"); + @TestMetadata("ParameterListDoNotWrap.after.inv.kt") + public void testParameterListDoNotWrap() throws Exception { + runTest("idea/testData/formatter/trailingComma/valueParameters/ParameterListDoNotWrap.after.inv.kt"); } - @TestMetadata("PrimaryConstructor.after.inv.kt") - public void testPrimaryConstructor() throws Exception { - runTest("idea/testData/formatter/trailingComma/valueParameters/PrimaryConstructor.after.inv.kt"); + @TestMetadata("ParameterListWrapAlways.after.inv.kt") + public void testParameterListWrapAlways() throws Exception { + runTest("idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAlways.after.inv.kt"); } - @TestMetadata("SecondConstructor.after.inv.kt") - public void testSecondConstructor() throws Exception { - runTest("idea/testData/formatter/trailingComma/valueParameters/SecondConstructor.after.inv.kt"); + @TestMetadata("ParameterListWrapAsNeeded.after.inv.kt") + public void testParameterListWrapAsNeeded() throws Exception { + runTest("idea/testData/formatter/trailingComma/valueParameters/ParameterListWrapAsNeeded.after.inv.kt"); } } }