TrailingCommaPostFormatProcessor: should work with call-site in limited mode

* remove useless comma
* format call if comma exists

#KT-39079 Fixed
This commit is contained in:
Dmitry Gridin
2020-05-22 16:43:23 +07:00
parent 86827dfc92
commit 262c9e6858
21 changed files with 301 additions and 279 deletions
@@ -40,14 +40,18 @@ private val TYPES_WITH_TRAILING_COMMA = TokenSet.orSet(
TYPES_WITH_TRAILING_COMMA_ON_CALL_SITE,
)
fun UserDataHolder.addTrailingCommaIsAllowedForThis(): Boolean {
fun PsiElement.canAddTrailingCommaWithRegistryCheck(): Boolean {
val type = elementType(this) ?: return false
return type in TYPES_WITH_TRAILING_COMMA_ON_DECLARATION_SITE ||
trailingCommaIsAllowedOnCallSite() && type in TYPES_WITH_TRAILING_COMMA_ON_CALL_SITE
}
fun KotlinCodeStyleSettings.addTrailingCommaIsAllowedFor(element: UserDataHolder): Boolean =
ALLOW_TRAILING_COMMA && element.addTrailingCommaIsAllowedForThis()
fun KotlinCodeStyleSettings.addTrailingCommaIsAllowedFor(element: UserDataHolder): Boolean = when (elementType(element)) {
null -> false
in TYPES_WITH_TRAILING_COMMA_ON_DECLARATION_SITE -> ALLOW_TRAILING_COMMA
in TYPES_WITH_TRAILING_COMMA_ON_CALL_SITE -> ALLOW_TRAILING_COMMA_ON_CALL_SITE || trailingCommaIsAllowedOnCallSite()
else -> false
}
private fun elementType(userDataHolder: UserDataHolder): IElementType? = when (userDataHolder) {
is ASTNode -> PsiUtilCore.getElementType(userDataHolder)
@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.idea.formatter.trailingComma.TrailingCommaHelper.fin
import org.jetbrains.kotlin.idea.formatter.trailingComma.TrailingCommaHelper.trailingCommaOrLastElement
import org.jetbrains.kotlin.idea.formatter.trailingComma.TrailingCommaState
import org.jetbrains.kotlin.idea.formatter.trailingComma.addTrailingCommaIsAllowedFor
import org.jetbrains.kotlin.idea.formatter.trailingComma.addTrailingCommaIsAllowedForThis
import org.jetbrains.kotlin.idea.util.leafIgnoringWhitespace
import org.jetbrains.kotlin.idea.util.leafIgnoringWhitespaceAndComments
import org.jetbrains.kotlin.psi.KtElement
@@ -40,12 +39,8 @@ class TrailingCommaPostFormatProcessor : PostFormatProcessor {
private class TrailingCommaPostFormatVisitor(val settings: CodeStyleSettings) : TrailingCommaVisitor() {
private val myPostProcessor = PostFormatProcessorHelper(settings.kotlinCommonSettings)
override fun process(trailingCommaContext: TrailingCommaContext) {
val ktElement = trailingCommaContext.ktElement
if (!ktElement.addTrailingCommaIsAllowedForThis()) return
processIfInRange(ktElement) {
processCommaOwner(trailingCommaContext)
}
override fun process(trailingCommaContext: TrailingCommaContext) = processIfInRange(trailingCommaContext.ktElement) {
processCommaOwner(trailingCommaContext)
}
private fun processIfInRange(element: KtElement, block: () -> Unit = {}) {
@@ -40,7 +40,7 @@ class TrailingCommaInspection(
override fun process(trailingCommaContext: TrailingCommaContext) {
val element = trailingCommaContext.ktElement
if (!element.addTrailingCommaIsAllowedForThis()) return
if (!element.canAddTrailingCommaWithRegistryCheck()) return
useTrailingComma = CodeStyle.getSettings(element.project).kotlinCustomSettings.ALLOW_TRAILING_COMMA
when (trailingCommaContext.state) {
@@ -10,7 +10,7 @@ import com.intellij.codeInsight.intention.LowPriorityAction
import com.intellij.openapi.editor.Editor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.formatter.kotlinCustomSettings
import org.jetbrains.kotlin.idea.formatter.trailingComma.addTrailingCommaIsAllowedForThis
import org.jetbrains.kotlin.idea.formatter.trailingComma.canAddTrailingCommaWithRegistryCheck
import org.jetbrains.kotlin.psi.KtElement
class TrailingCommaIntention : SelfTargetingIntention<KtElement>(
@@ -22,7 +22,7 @@ class TrailingCommaIntention : SelfTargetingIntention<KtElement>(
kotlinCustomSettings.ALLOW_TRAILING_COMMA = !kotlinCustomSettings.ALLOW_TRAILING_COMMA
}
override fun isApplicableTo(element: KtElement, caretOffset: Int): Boolean = element.addTrailingCommaIsAllowedForThis().also {
override fun isApplicableTo(element: KtElement, caretOffset: Int): Boolean = element.canAddTrailingCommaWithRegistryCheck().also {
val actionNumber = 1.takeIf { CodeStyle.getSettings(element.project).kotlinCustomSettings.ALLOW_TRAILING_COMMA } ?: 0
setTextGetter(KotlinBundle.lazyMessage("intention.trailing.comma.custom.text", actionNumber))
}
@@ -13,7 +13,7 @@ import com.intellij.psi.codeStyle.CodeStyleManager
import org.jetbrains.kotlin.idea.core.util.containsLineBreakInRange
import org.jetbrains.kotlin.idea.formatter.trailingComma.TrailingCommaHelper
import org.jetbrains.kotlin.idea.formatter.trailingComma.TrailingCommaState
import org.jetbrains.kotlin.idea.formatter.trailingComma.addTrailingCommaIsAllowedForThis
import org.jetbrains.kotlin.idea.formatter.trailingComma.canAddTrailingCommaWithRegistryCheck
import org.jetbrains.kotlin.idea.formatter.trailingComma.existsOrMissing
import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.kotlin.psi.KtFile
@@ -26,7 +26,7 @@ class JoinWithTrailingCommaHandler : JoinLinesHandlerDelegate {
val commaOwner = file.findElementAt(start)
?.parentsWithSelf
?.filter { !document.containsLineBreakInRange(it.textRange) }
?.findLast { it.addTrailingCommaIsAllowedForThis() } as? KtElement
?.findLast { it.canAddTrailingCommaWithRegistryCheck() } as? KtElement
?: return CANNOT_JOIN
if (TrailingCommaState.stateForElement(commaOwner).existsOrMissing) return CANNOT_JOIN
@@ -3,7 +3,7 @@
@Anno([1])
fun a() = Unit
@Anno([1, ])
@Anno([1])
fun a() = Unit
@Anno([1
@@ -22,7 +22,7 @@ fun a() = Unit
@Anno([1, 2])
fun a() = Unit
@Anno([1, 2, ])
@Anno([1, 2])
fun a() = Unit
@Anno([1, 2
@@ -41,7 +41,7 @@ fun a() = Unit
@Anno([1, 2, 2])
fun a() = Unit
@Anno([1, 2, 2, ])
@Anno([1, 2, 2])
fun a() = Unit
@Anno(["1"
@@ -74,8 +74,8 @@ fun a() = Unit
/*
*/
// d
1/*
*/,/*
1,/*
*//*
*/
])
fun a() = Unit
@@ -91,8 +91,8 @@ fun a() = Unit
@Anno([
1,
2/*
*/,/*
2,/*
*//*
*/
])
fun a() = Unit
@@ -3,7 +3,7 @@
@Anno([1])
fun a() = Unit
@Anno([1, ])
@Anno([1])
fun a() = Unit
@Anno([1
@@ -22,7 +22,7 @@ fun a() = Unit
@Anno([1, 2])
fun a() = Unit
@Anno([1, 2, ])
@Anno([1, 2])
fun a() = Unit
@Anno([1, 2
@@ -41,7 +41,7 @@ fun a() = Unit
@Anno([1, 2, 2])
fun a() = Unit
@Anno([1, 2, 2, ])
@Anno([1, 2, 2])
fun a() = Unit
@Anno(["1"
@@ -74,8 +74,8 @@ fun a() = Unit
/*
*/
// d
1/*
*/,/*
1,/*
*//*
*/
])
fun a() = Unit
@@ -91,8 +91,8 @@ fun a() = Unit
@Anno([
1,
2/*
*/,/*
2,/*
*//*
*/
])
fun a() = Unit
@@ -25,7 +25,7 @@ fun foo() {
foofoo
]
testtest[foofoo, ]
testtest[foofoo]
testtest[foofoo, testtest[testtest[foofoo]]]
@@ -34,9 +34,9 @@ fun foo() {
testtest[testtest[foofoo]],
]
testtest[foofoo, testtest[testtest[foofoo, ]], testsa]
testtest[foofoo, testtest[testtest[foofoo]], testsa]
testtest[foofoo, seee, testtest[testtest[foofoo, ]], testsa]
testtest[foofoo, seee, testtest[testtest[foofoo]], testsa]
useCallable["A", Callable { println["Hello world"] }]
@@ -48,7 +48,7 @@ fun foo() {
useCallable[Callable { println["Hello world"] }]
useCallable[Callable { println["Hello world"] }, ]
useCallable[Callable { println["Hello world"] }]
useCallable[
Callable {
@@ -76,7 +76,7 @@ fun foo() {
useCallable[{ println["Hello world"] }]
useCallable[{ println["Hello world"] }, ]
useCallable[{ println["Hello world"] }]
useCallable[
{ println["Hello world"] },
@@ -104,7 +104,7 @@ fun foo() {
override fun call() {
println["Hello world"]
}
}, foo[0, ]]
}, foo[0]]
useCallable[object : Callable<Unit> {
override fun call() {
@@ -112,11 +112,13 @@ fun foo() {
}
}]
useCallable[object : Callable<Unit> {
override fun call() {
println["Hello world"]
}
}, ]
useCallable[
object : Callable<Unit> {
override fun call() {
println["Hello world"]
}
},
]
useCallable[object : Callable<Unit> {
override fun call() {
@@ -171,7 +173,7 @@ fun foo() {
foofoo
]
testtest[foofoo,/**/]
testtest[foofoo/**/]
testtest[foofoo, foofoo, foofoo, foofoo/*
*/, /* */ bar
@@ -184,7 +186,7 @@ fun foo() {
foofoo
]
testtest[foofoo,/**/]
testtest[foofoo/**/]
testtest[
foofoo, fososos,/*
@@ -192,16 +194,16 @@ fun foo() {
testtest[testtest[foofoo]],
]
testtest[foofoo, testtest[testtest[foofoo, ]], /**/testsa]
testtest[foofoo, testtest[testtest[foofoo]], /**/testsa]
testtest[foofoo, testtest[testtest[foofoo, ]]/* */, /**/testsa]
testtest[foofoo, testtest[testtest[foofoo]]/* */, /**/testsa]
testtest[foofoo, testtest[testtest[foofoo, ]]/*
testtest[foofoo, testtest[testtest[foofoo]]/*
*/, testsa]
testtest[foofoo, seee, testtest[testtest[foofoo, ]], /**/testsa]
testtest[foofoo, seee, testtest[testtest[foofoo]], /**/testsa]
testtest[foofoo, seee, testtest[testtest[foofoo, ]], /*
testtest[foofoo, seee, testtest[testtest[foofoo]], /*
*/testsa]
useCallable["B", "C", Callable {
@@ -25,7 +25,7 @@ fun foo() {
foofoo
]
testtest[foofoo, ]
testtest[foofoo]
testtest[foofoo, testtest[testtest[foofoo]]]
@@ -34,9 +34,9 @@ fun foo() {
testtest[testtest[foofoo]],
]
testtest[foofoo, testtest[testtest[foofoo, ]], testsa]
testtest[foofoo, testtest[testtest[foofoo]], testsa]
testtest[foofoo, seee, testtest[testtest[foofoo, ]], testsa]
testtest[foofoo, seee, testtest[testtest[foofoo]], testsa]
useCallable["A", Callable { println["Hello world"] }]
@@ -48,7 +48,7 @@ fun foo() {
useCallable[Callable { println["Hello world"] }]
useCallable[Callable { println["Hello world"] }, ]
useCallable[Callable { println["Hello world"] }]
useCallable[
Callable {
@@ -76,7 +76,7 @@ fun foo() {
useCallable[{ println["Hello world"] }]
useCallable[{ println["Hello world"] }, ]
useCallable[{ println["Hello world"] }]
useCallable[
{ println["Hello world"] },
@@ -104,7 +104,7 @@ fun foo() {
override fun call() {
println["Hello world"]
}
}, foo[0, ]]
}, foo[0]]
useCallable[object : Callable<Unit> {
override fun call() {
@@ -112,11 +112,13 @@ fun foo() {
}
}]
useCallable[object : Callable<Unit> {
override fun call() {
println["Hello world"]
}
}, ]
useCallable[
object : Callable<Unit> {
override fun call() {
println["Hello world"]
}
},
]
useCallable[object : Callable<Unit> {
override fun call() {
@@ -171,7 +173,7 @@ fun foo() {
foofoo
]
testtest[foofoo,/**/]
testtest[foofoo/**/]
testtest[foofoo, foofoo, foofoo, foofoo/*
*/, /* */ bar
@@ -184,7 +186,7 @@ fun foo() {
foofoo
]
testtest[foofoo,/**/]
testtest[foofoo/**/]
testtest[
foofoo, fososos,/*
@@ -192,16 +194,16 @@ fun foo() {
testtest[testtest[foofoo]],
]
testtest[foofoo, testtest[testtest[foofoo, ]], /**/testsa]
testtest[foofoo, testtest[testtest[foofoo]], /**/testsa]
testtest[foofoo, testtest[testtest[foofoo, ]]/* */, /**/testsa]
testtest[foofoo, testtest[testtest[foofoo]]/* */, /**/testsa]
testtest[foofoo, testtest[testtest[foofoo, ]]/*
testtest[foofoo, testtest[testtest[foofoo]]/*
*/, testsa]
testtest[foofoo, seee, testtest[testtest[foofoo, ]], /**/testsa]
testtest[foofoo, seee, testtest[testtest[foofoo]], /**/testsa]
testtest[foofoo, seee, testtest[testtest[foofoo, ]], /*
testtest[foofoo, seee, testtest[testtest[foofoo]], /*
*/testsa]
useCallable["B", "C", Callable {
@@ -35,19 +35,19 @@ fun foo() {
foofoo
>()
testtest<foofoo, >()
testtest<foofoo>()
testtest<foofoo, testtest<testtest<foofoo>>>()
testtest<foofoo, fososos, testtest<testtest<foofoo>>, >()
testtest<foofoo, fososos, testtest<testtest<foofoo>>>()
testtest<
foofoo, fososos, testtest<testtest<foofoo>>,
>()
testtest<foofoo, testtest<testtest<foofoo, >>, testsa>()
testtest<foofoo, testtest<testtest<foofoo>>, testsa>()
testtest<foofoo, *, testtest<testtest<foofoo, >>, testsa>()
testtest<foofoo, *, testtest<testtest<foofoo>>, testsa>()
testtest<
foofoo, foofoo, foofoo, foofoo,
@@ -80,7 +80,7 @@ fun foo() {
foofoo
>()
testtest<foofoo,/**/>()
testtest<foofoo/**/>()
testtest<foofoo, foofoo, foofoo, foofoo/*
*/, /* */ bar
@@ -93,7 +93,7 @@ fun foo() {
foofoo
>()
testtest<foofoo,/**/>()
testtest<foofoo/**/>()
testtest<
foofoo,/*
@@ -110,15 +110,15 @@ fun foo() {
testtest<testtest<foofoo>>,
>()
testtest<foofoo, testtest<testtest<foofoo, >>, /**/testsa>()
testtest<foofoo, testtest<testtest<foofoo>>, /**/testsa>()
testtest<foofoo, testtest<testtest<foofoo, >>/* */, /**/testsa>()
testtest<foofoo, testtest<testtest<foofoo>>/* */, /**/testsa>()
testtest<foofoo, testtest<testtest<foofoo, >>/*
testtest<foofoo, testtest<testtest<foofoo>>/*
*/, testsa>()
testtest<foofoo, seee, testtest<testtest<foofoo, >>, /**/testsa>()
testtest<foofoo, seee, testtest<testtest<foofoo>>, /**/testsa>()
testtest<foofoo, seee, testtest<testtest<foofoo, >>, /*
testtest<foofoo, seee, testtest<testtest<foofoo>>, /*
*/testsa>()
}
@@ -35,19 +35,19 @@ fun foo() {
foofoo
>()
testtest<foofoo, >()
testtest<foofoo>()
testtest<foofoo, testtest<testtest<foofoo>>>()
testtest<foofoo, fososos, testtest<testtest<foofoo>>, >()
testtest<foofoo, fososos, testtest<testtest<foofoo>>>()
testtest<
foofoo, fososos, testtest<testtest<foofoo>>,
>()
testtest<foofoo, testtest<testtest<foofoo, >>, testsa>()
testtest<foofoo, testtest<testtest<foofoo>>, testsa>()
testtest<foofoo, *, testtest<testtest<foofoo, >>, testsa>()
testtest<foofoo, *, testtest<testtest<foofoo>>, testsa>()
testtest<
foofoo, foofoo, foofoo, foofoo,
@@ -80,7 +80,7 @@ fun foo() {
foofoo
>()
testtest<foofoo,/**/>()
testtest<foofoo/**/>()
testtest<foofoo, foofoo, foofoo, foofoo/*
*/, /* */ bar
@@ -93,7 +93,7 @@ fun foo() {
foofoo
>()
testtest<foofoo,/**/>()
testtest<foofoo/**/>()
testtest<
foofoo,/*
@@ -110,15 +110,15 @@ fun foo() {
testtest<testtest<foofoo>>,
>()
testtest<foofoo, testtest<testtest<foofoo, >>, /**/testsa>()
testtest<foofoo, testtest<testtest<foofoo>>, /**/testsa>()
testtest<foofoo, testtest<testtest<foofoo, >>/* */, /**/testsa>()
testtest<foofoo, testtest<testtest<foofoo>>/* */, /**/testsa>()
testtest<foofoo, testtest<testtest<foofoo, >>/*
testtest<foofoo, testtest<testtest<foofoo>>/*
*/, testsa>()
testtest<foofoo, seee, testtest<testtest<foofoo, >>, /**/testsa>()
testtest<foofoo, seee, testtest<testtest<foofoo>>, /**/testsa>()
testtest<foofoo, seee, testtest<testtest<foofoo, >>, /*
testtest<foofoo, seee, testtest<testtest<foofoo>>, /*
*/testsa>()
}
@@ -26,15 +26,15 @@ fun foo() {
foofoo
)
testtest(foofoo, )
testtest(foofoo)
testtest(foofoo, testtest(testtest(foofoo)))
testtest(foofoo, fososos, testtest(testtest(foofoo)), )
testtest(foofoo, fososos, testtest(testtest(foofoo)))
testtest(foofoo, testtest(testtest(foofoo, )), testsa)
testtest(foofoo, testtest(testtest(foofoo)), testsa)
testtest(foofoo, seee, testtest(testtest(foofoo, )), testsa)
testtest(foofoo, seee, testtest(testtest(foofoo)), testsa)
useCallable("A", Callable { println("Hello world") })
@@ -46,7 +46,7 @@ fun foo() {
useCallable(Callable { println("Hello world") })
useCallable(Callable { println("Hello world") }, )
useCallable(Callable { println("Hello world") })
useCallable(Callable { println("Hello world") }
)
@@ -68,7 +68,7 @@ fun foo() {
useCallable({ println("Hello world") })
useCallable({ println("Hello world") }, )
useCallable({ println("Hello world") })
useCallable({ println("Hello world") }
)
@@ -90,7 +90,7 @@ fun foo() {
useCallable(foo() { println("Hello world") })
useCallable(foo() { println("Hello world") }, )
useCallable(foo() { println("Hello world") })
useCallable(foo() { println("Hello world") }
)
@@ -128,11 +128,13 @@ fun foo() {
}
})
useCallable(object : Callable<Unit> {
override fun call() {
println("Hello world")
}
}, )
useCallable(
object : Callable<Unit> {
override fun call() {
println("Hello world")
}
},
)
useCallable(object : Callable<Unit> {
override fun call() {
@@ -187,7 +189,7 @@ fun foo() {
foofoo
)
testtest(foofoo,/**/)
testtest(foofoo/**/)
testtest(foofoo, foofoo, foofoo, foofoo/*
*/, /* */ bar
@@ -200,7 +202,7 @@ fun foo() {
foofoo
)
testtest(foofoo,/**/)
testtest(foofoo/**/)
testtest(
foofoo, fososos,/*
@@ -208,16 +210,16 @@ fun foo() {
testtest(testtest(foofoo)),
)
testtest(foofoo, testtest(testtest(foofoo, )), /**/testsa)
testtest(foofoo, testtest(testtest(foofoo)), /**/testsa)
testtest(foofoo, testtest(testtest(foofoo, ))/* */, /**/testsa)
testtest(foofoo, testtest(testtest(foofoo))/* */, /**/testsa)
testtest(foofoo, testtest(testtest(foofoo, ))/*
testtest(foofoo, testtest(testtest(foofoo))/*
*/, testsa)
testtest(foofoo, seee, testtest(testtest(foofoo, )), /**/testsa)
testtest(foofoo, seee, testtest(testtest(foofoo)), /**/testsa)
testtest(foofoo, seee, testtest(testtest(foofoo, )), /*
testtest(foofoo, seee, testtest(testtest(foofoo)), /*
*/testsa)
useCallable("B", "C", Callable {
@@ -265,9 +267,9 @@ fun foo() {
fun test() {
baz(
f = fun(it: Int): String = "$it" /*dwdwd
*/,
name = "" /*
*/,
f = fun(it: Int): String = "$it", /*dwdwd
*/
name = "", /*
*/
)
}
@@ -26,15 +26,15 @@ fun foo() {
foofoo
)
testtest(foofoo, )
testtest(foofoo)
testtest(foofoo, testtest(testtest(foofoo)))
testtest(foofoo, fososos, testtest(testtest(foofoo)), )
testtest(foofoo, fososos, testtest(testtest(foofoo)))
testtest(foofoo, testtest(testtest(foofoo, )), testsa)
testtest(foofoo, testtest(testtest(foofoo)), testsa)
testtest(foofoo, seee, testtest(testtest(foofoo, )), testsa)
testtest(foofoo, seee, testtest(testtest(foofoo)), testsa)
useCallable("A", Callable { println("Hello world") })
@@ -46,7 +46,7 @@ fun foo() {
useCallable(Callable { println("Hello world") })
useCallable(Callable { println("Hello world") }, )
useCallable(Callable { println("Hello world") })
useCallable(Callable { println("Hello world") }
)
@@ -68,7 +68,7 @@ fun foo() {
useCallable({ println("Hello world") })
useCallable({ println("Hello world") }, )
useCallable({ println("Hello world") })
useCallable({ println("Hello world") }
)
@@ -90,7 +90,7 @@ fun foo() {
useCallable(foo() { println("Hello world") })
useCallable(foo() { println("Hello world") }, )
useCallable(foo() { println("Hello world") })
useCallable(foo() { println("Hello world") }
)
@@ -128,11 +128,13 @@ fun foo() {
}
})
useCallable(object : Callable<Unit> {
override fun call() {
println("Hello world")
}
}, )
useCallable(
object : Callable<Unit> {
override fun call() {
println("Hello world")
}
},
)
useCallable(object : Callable<Unit> {
override fun call() {
@@ -187,7 +189,7 @@ fun foo() {
foofoo
)
testtest(foofoo,/**/)
testtest(foofoo/**/)
testtest(foofoo, foofoo, foofoo, foofoo/*
*/, /* */ bar
@@ -200,7 +202,7 @@ fun foo() {
foofoo
)
testtest(foofoo,/**/)
testtest(foofoo/**/)
testtest(
foofoo, fososos,/*
@@ -208,16 +210,16 @@ fun foo() {
testtest(testtest(foofoo)),
)
testtest(foofoo, testtest(testtest(foofoo, )), /**/testsa)
testtest(foofoo, testtest(testtest(foofoo)), /**/testsa)
testtest(foofoo, testtest(testtest(foofoo, ))/* */, /**/testsa)
testtest(foofoo, testtest(testtest(foofoo))/* */, /**/testsa)
testtest(foofoo, testtest(testtest(foofoo, ))/*
testtest(foofoo, testtest(testtest(foofoo))/*
*/, testsa)
testtest(foofoo, seee, testtest(testtest(foofoo, )), /**/testsa)
testtest(foofoo, seee, testtest(testtest(foofoo)), /**/testsa)
testtest(foofoo, seee, testtest(testtest(foofoo, )), /*
testtest(foofoo, seee, testtest(testtest(foofoo)), /*
*/testsa)
useCallable("B", "C", Callable {
@@ -265,9 +267,9 @@ fun foo() {
fun test() {
baz(
f = fun(it: Int): String = "$it" /*dwdwd
*/,
name = "" /*
*/,
f = fun(it: Int): String = "$it", /*dwdwd
*/
name = "", /*
*/
)
}
@@ -26,15 +26,15 @@ fun foo() {
foofoo
)
testtest(foofoo, )
testtest(foofoo)
testtest(foofoo, testtest(testtest(foofoo)))
testtest(foofoo, fososos, testtest(testtest(foofoo)), )
testtest(foofoo, fososos, testtest(testtest(foofoo)))
testtest(foofoo, testtest(testtest(foofoo, )), testsa)
testtest(foofoo, testtest(testtest(foofoo)), testsa)
testtest(foofoo, seee, testtest(testtest(foofoo, )), testsa)
testtest(foofoo, seee, testtest(testtest(foofoo)), testsa)
useCallable("A", Callable { println("Hello world") })
@@ -46,7 +46,7 @@ fun foo() {
useCallable(Callable { println("Hello world") })
useCallable(Callable { println("Hello world") }, )
useCallable(Callable { println("Hello world") })
useCallable(Callable { println("Hello world") }
)
@@ -68,7 +68,7 @@ fun foo() {
useCallable({ println("Hello world") })
useCallable({ println("Hello world") }, )
useCallable({ println("Hello world") })
useCallable({ println("Hello world") }
)
@@ -90,7 +90,7 @@ fun foo() {
useCallable(foo() { println("Hello world") })
useCallable(foo() { println("Hello world") }, )
useCallable(foo() { println("Hello world") })
useCallable(foo() { println("Hello world") }
)
@@ -128,11 +128,13 @@ fun foo() {
}
})
useCallable(object : Callable<Unit> {
override fun call() {
println("Hello world")
}
}, )
useCallable(
object : Callable<Unit> {
override fun call() {
println("Hello world")
}
},
)
useCallable(object : Callable<Unit> {
override fun call() {
@@ -187,7 +189,7 @@ fun foo() {
foofoo
)
testtest(foofoo,/**/)
testtest(foofoo/**/)
testtest(foofoo, foofoo, foofoo, foofoo/*
*/, /* */ bar
@@ -200,7 +202,7 @@ fun foo() {
foofoo
)
testtest(foofoo,/**/)
testtest(foofoo/**/)
testtest(
foofoo, fososos,/*
@@ -208,16 +210,16 @@ fun foo() {
testtest(testtest(foofoo)),
)
testtest(foofoo, testtest(testtest(foofoo, )), /**/testsa)
testtest(foofoo, testtest(testtest(foofoo)), /**/testsa)
testtest(foofoo, testtest(testtest(foofoo, ))/* */, /**/testsa)
testtest(foofoo, testtest(testtest(foofoo))/* */, /**/testsa)
testtest(foofoo, testtest(testtest(foofoo, ))/*
testtest(foofoo, testtest(testtest(foofoo))/*
*/, testsa)
testtest(foofoo, seee, testtest(testtest(foofoo, )), /**/testsa)
testtest(foofoo, seee, testtest(testtest(foofoo)), /**/testsa)
testtest(foofoo, seee, testtest(testtest(foofoo, )), /*
testtest(foofoo, seee, testtest(testtest(foofoo)), /*
*/testsa)
useCallable("B", "C", Callable {
@@ -265,9 +267,9 @@ fun foo() {
fun test() {
baz(
f = fun(it: Int): String = "$it" /*dwdwd
*/,
name = "" /*
*/,
f = fun(it: Int): String = "$it", /*dwdwd
*/
name = "", /*
*/
)
}
@@ -26,15 +26,15 @@ fun foo() {
foofoo
)
testtest(foofoo, )
testtest(foofoo)
testtest(foofoo, testtest(testtest(foofoo)))
testtest(foofoo, fososos, testtest(testtest(foofoo)), )
testtest(foofoo, fososos, testtest(testtest(foofoo)))
testtest(foofoo, testtest(testtest(foofoo, )), testsa)
testtest(foofoo, testtest(testtest(foofoo)), testsa)
testtest(foofoo, seee, testtest(testtest(foofoo, )), testsa)
testtest(foofoo, seee, testtest(testtest(foofoo)), testsa)
useCallable("A", Callable { println("Hello world") })
@@ -46,7 +46,7 @@ fun foo() {
useCallable(Callable { println("Hello world") })
useCallable(Callable { println("Hello world") }, )
useCallable(Callable { println("Hello world") })
useCallable(Callable { println("Hello world") }
)
@@ -68,7 +68,7 @@ fun foo() {
useCallable({ println("Hello world") })
useCallable({ println("Hello world") }, )
useCallable({ println("Hello world") })
useCallable({ println("Hello world") }
)
@@ -90,7 +90,7 @@ fun foo() {
useCallable(foo() { println("Hello world") })
useCallable(foo() { println("Hello world") }, )
useCallable(foo() { println("Hello world") })
useCallable(foo() { println("Hello world") }
)
@@ -128,11 +128,13 @@ fun foo() {
}
})
useCallable(object : Callable<Unit> {
override fun call() {
println("Hello world")
}
}, )
useCallable(
object : Callable<Unit> {
override fun call() {
println("Hello world")
}
},
)
useCallable(object : Callable<Unit> {
override fun call() {
@@ -187,7 +189,7 @@ fun foo() {
foofoo
)
testtest(foofoo,/**/)
testtest(foofoo/**/)
testtest(foofoo, foofoo, foofoo, foofoo/*
*/, /* */ bar
@@ -200,7 +202,7 @@ fun foo() {
foofoo
)
testtest(foofoo,/**/)
testtest(foofoo/**/)
testtest(
foofoo, fososos,/*
@@ -208,16 +210,16 @@ fun foo() {
testtest(testtest(foofoo)),
)
testtest(foofoo, testtest(testtest(foofoo, )), /**/testsa)
testtest(foofoo, testtest(testtest(foofoo)), /**/testsa)
testtest(foofoo, testtest(testtest(foofoo, ))/* */, /**/testsa)
testtest(foofoo, testtest(testtest(foofoo))/* */, /**/testsa)
testtest(foofoo, testtest(testtest(foofoo, ))/*
testtest(foofoo, testtest(testtest(foofoo))/*
*/, testsa)
testtest(foofoo, seee, testtest(testtest(foofoo, )), /**/testsa)
testtest(foofoo, seee, testtest(testtest(foofoo)), /**/testsa)
testtest(foofoo, seee, testtest(testtest(foofoo, )), /*
testtest(foofoo, seee, testtest(testtest(foofoo)), /*
*/testsa)
useCallable("B", "C", Callable {
@@ -265,9 +267,9 @@ fun foo() {
fun test() {
baz(
f = fun(it: Int): String = "$it" /*dwdwd
*/,
name = "" /*
*/,
f = fun(it: Int): String = "$it", /*dwdwd
*/
name = "", /*
*/
)
}
@@ -50,22 +50,24 @@ fun foo() {
foofoo
)
testtest(foofoo, )
testtest(foofoo)
testtest(foofoo,
testtest(testtest(foofoo)))
testtest(foofoo,
testtest(
foofoo,
fososos,
testtest(testtest(foofoo)), )
testtest(testtest(foofoo)),
)
testtest(foofoo,
testtest(testtest(foofoo, )),
testtest(testtest(foofoo)),
testsa)
testtest(foofoo,
seee,
testtest(testtest(foofoo, )),
testtest(testtest(foofoo)),
testsa)
useCallable("A",
@@ -82,7 +84,7 @@ fun foo() {
useCallable(Callable { println("Hello world") })
useCallable(Callable { println("Hello world") }, )
useCallable(Callable { println("Hello world") })
useCallable(Callable { println("Hello world") }
)
@@ -108,7 +110,7 @@ fun foo() {
useCallable({ println("Hello world") })
useCallable({ println("Hello world") }, )
useCallable({ println("Hello world") })
useCallable({ println("Hello world") }
)
@@ -134,7 +136,7 @@ fun foo() {
useCallable(foo() { println("Hello world") })
useCallable(foo() { println("Hello world") }, )
useCallable(foo() { println("Hello world") })
useCallable(foo() { println("Hello world") }
)
@@ -177,11 +179,13 @@ fun foo() {
}
})
useCallable(object : Callable<Unit> {
override fun call() {
println("Hello world")
}
}, )
useCallable(
object : Callable<Unit> {
override fun call() {
println("Hello world")
}
},
)
useCallable(object : Callable<Unit> {
override fun call() {
@@ -254,7 +258,7 @@ fun foo() {
foofoo
)
testtest(foofoo,/**/)
testtest(foofoo/**/)
testtest(foofoo,
foofoo,
@@ -271,7 +275,7 @@ fun foo() {
foofoo
)
testtest(foofoo,/**/)
testtest(foofoo/**/)
testtest(
foofoo,
@@ -281,26 +285,26 @@ fun foo() {
)
testtest(foofoo,
testtest(testtest(foofoo, )), /**/
testtest(testtest(foofoo)), /**/
testsa)
testtest(foofoo,
testtest(testtest(foofoo, ))/* */, /**/
testtest(testtest(foofoo))/* */, /**/
testsa)
testtest(foofoo,
testtest(testtest(foofoo, ))/*
testtest(testtest(foofoo))/*
*/,
testsa)
testtest(foofoo,
seee,
testtest(testtest(foofoo, )), /**/
testtest(testtest(foofoo)), /**/
testsa)
testtest(foofoo,
seee,
testtest(testtest(foofoo, )), /*
testtest(testtest(foofoo)), /*
*/
testsa)
@@ -356,9 +360,9 @@ fun foo() {
fun test() {
baz(
f = fun(it: Int): String = "$it" /*dwdwd
*/,
name = "" /*
*/,
f = fun(it: Int): String = "$it", /*dwdwd
*/
name = "", /*
*/
)
}
@@ -50,22 +50,24 @@ fun foo() {
foofoo
)
testtest(foofoo, )
testtest(foofoo)
testtest(foofoo,
testtest(testtest(foofoo)))
testtest(foofoo,
testtest(
foofoo,
fososos,
testtest(testtest(foofoo)), )
testtest(testtest(foofoo)),
)
testtest(foofoo,
testtest(testtest(foofoo, )),
testtest(testtest(foofoo)),
testsa)
testtest(foofoo,
seee,
testtest(testtest(foofoo, )),
testtest(testtest(foofoo)),
testsa)
useCallable("A",
@@ -82,7 +84,7 @@ fun foo() {
useCallable(Callable { println("Hello world") })
useCallable(Callable { println("Hello world") }, )
useCallable(Callable { println("Hello world") })
useCallable(Callable { println("Hello world") }
)
@@ -108,7 +110,7 @@ fun foo() {
useCallable({ println("Hello world") })
useCallable({ println("Hello world") }, )
useCallable({ println("Hello world") })
useCallable({ println("Hello world") }
)
@@ -134,7 +136,7 @@ fun foo() {
useCallable(foo() { println("Hello world") })
useCallable(foo() { println("Hello world") }, )
useCallable(foo() { println("Hello world") })
useCallable(foo() { println("Hello world") }
)
@@ -177,11 +179,13 @@ fun foo() {
}
})
useCallable(object : Callable<Unit> {
override fun call() {
println("Hello world")
}
}, )
useCallable(
object : Callable<Unit> {
override fun call() {
println("Hello world")
}
},
)
useCallable(object : Callable<Unit> {
override fun call() {
@@ -254,7 +258,7 @@ fun foo() {
foofoo
)
testtest(foofoo,/**/)
testtest(foofoo/**/)
testtest(foofoo,
foofoo,
@@ -271,7 +275,7 @@ fun foo() {
foofoo
)
testtest(foofoo,/**/)
testtest(foofoo/**/)
testtest(
foofoo,
@@ -281,26 +285,26 @@ fun foo() {
)
testtest(foofoo,
testtest(testtest(foofoo, )), /**/
testtest(testtest(foofoo)), /**/
testsa)
testtest(foofoo,
testtest(testtest(foofoo, ))/* */, /**/
testtest(testtest(foofoo))/* */, /**/
testsa)
testtest(foofoo,
testtest(testtest(foofoo, ))/*
testtest(testtest(foofoo))/*
*/,
testsa)
testtest(foofoo,
seee,
testtest(testtest(foofoo, )), /**/
testtest(testtest(foofoo)), /**/
testsa)
testtest(foofoo,
seee,
testtest(testtest(foofoo, )), /*
testtest(testtest(foofoo)), /*
*/
testsa)
@@ -356,9 +360,9 @@ fun foo() {
fun test() {
baz(
f = fun(it: Int): String = "$it" /*dwdwd
*/,
name = "" /*
*/,
f = fun(it: Int): String = "$it", /*dwdwd
*/
name = "", /*
*/
)
}
@@ -26,15 +26,15 @@ fun foo() {
foofoo
)
testtest(foofoo, )
testtest(foofoo)
testtest(foofoo, testtest(testtest(foofoo)))
testtest(foofoo, fososos, testtest(testtest(foofoo)), )
testtest(foofoo, fososos, testtest(testtest(foofoo)))
testtest(foofoo, testtest(testtest(foofoo, )), testsa)
testtest(foofoo, testtest(testtest(foofoo)), testsa)
testtest(foofoo, seee, testtest(testtest(foofoo, )), testsa)
testtest(foofoo, seee, testtest(testtest(foofoo)), testsa)
useCallable("A", Callable { println("Hello world") })
@@ -46,7 +46,7 @@ fun foo() {
useCallable(Callable { println("Hello world") })
useCallable(Callable { println("Hello world") }, )
useCallable(Callable { println("Hello world") })
useCallable(Callable { println("Hello world") }
)
@@ -68,7 +68,7 @@ fun foo() {
useCallable({ println("Hello world") })
useCallable({ println("Hello world") }, )
useCallable({ println("Hello world") })
useCallable({ println("Hello world") }
)
@@ -90,7 +90,7 @@ fun foo() {
useCallable(foo() { println("Hello world") })
useCallable(foo() { println("Hello world") }, )
useCallable(foo() { println("Hello world") })
useCallable(foo() { println("Hello world") }
)
@@ -128,11 +128,13 @@ fun foo() {
}
})
useCallable(object : Callable<Unit> {
override fun call() {
println("Hello world")
}
}, )
useCallable(
object : Callable<Unit> {
override fun call() {
println("Hello world")
}
},
)
useCallable(object : Callable<Unit> {
override fun call() {
@@ -187,7 +189,7 @@ fun foo() {
foofoo
)
testtest(foofoo,/**/)
testtest(foofoo/**/)
testtest(foofoo, foofoo, foofoo, foofoo/*
*/, /* */ bar
@@ -200,7 +202,7 @@ fun foo() {
foofoo
)
testtest(foofoo,/**/)
testtest(foofoo/**/)
testtest(
foofoo, fososos,/*
@@ -208,16 +210,16 @@ fun foo() {
testtest(testtest(foofoo)),
)
testtest(foofoo, testtest(testtest(foofoo, )), /**/testsa)
testtest(foofoo, testtest(testtest(foofoo)), /**/testsa)
testtest(foofoo, testtest(testtest(foofoo, ))/* */, /**/testsa)
testtest(foofoo, testtest(testtest(foofoo))/* */, /**/testsa)
testtest(foofoo, testtest(testtest(foofoo, ))/*
testtest(foofoo, testtest(testtest(foofoo))/*
*/, testsa)
testtest(foofoo, seee, testtest(testtest(foofoo, )), /**/testsa)
testtest(foofoo, seee, testtest(testtest(foofoo)), /**/testsa)
testtest(foofoo, seee, testtest(testtest(foofoo, )), /*
testtest(foofoo, seee, testtest(testtest(foofoo)), /*
*/testsa)
useCallable("B", "C", Callable {
@@ -265,9 +267,9 @@ fun foo() {
fun test() {
baz(
f = fun(it: Int): String = "$it" /*dwdwd
*/,
name = "" /*
*/,
f = fun(it: Int): String = "$it", /*dwdwd
*/
name = "", /*
*/
)
}
@@ -26,15 +26,15 @@ fun foo() {
foofoo
)
testtest(foofoo, )
testtest(foofoo)
testtest(foofoo, testtest(testtest(foofoo)))
testtest(foofoo, fososos, testtest(testtest(foofoo)), )
testtest(foofoo, fososos, testtest(testtest(foofoo)))
testtest(foofoo, testtest(testtest(foofoo, )), testsa)
testtest(foofoo, testtest(testtest(foofoo)), testsa)
testtest(foofoo, seee, testtest(testtest(foofoo, )), testsa)
testtest(foofoo, seee, testtest(testtest(foofoo)), testsa)
useCallable("A", Callable { println("Hello world") })
@@ -46,7 +46,7 @@ fun foo() {
useCallable(Callable { println("Hello world") })
useCallable(Callable { println("Hello world") }, )
useCallable(Callable { println("Hello world") })
useCallable(Callable { println("Hello world") }
)
@@ -68,7 +68,7 @@ fun foo() {
useCallable({ println("Hello world") })
useCallable({ println("Hello world") }, )
useCallable({ println("Hello world") })
useCallable({ println("Hello world") }
)
@@ -90,7 +90,7 @@ fun foo() {
useCallable(foo() { println("Hello world") })
useCallable(foo() { println("Hello world") }, )
useCallable(foo() { println("Hello world") })
useCallable(foo() { println("Hello world") }
)
@@ -128,11 +128,13 @@ fun foo() {
}
})
useCallable(object : Callable<Unit> {
override fun call() {
println("Hello world")
}
}, )
useCallable(
object : Callable<Unit> {
override fun call() {
println("Hello world")
}
},
)
useCallable(object : Callable<Unit> {
override fun call() {
@@ -187,7 +189,7 @@ fun foo() {
foofoo
)
testtest(foofoo,/**/)
testtest(foofoo/**/)
testtest(foofoo, foofoo, foofoo, foofoo/*
*/, /* */ bar
@@ -200,7 +202,7 @@ fun foo() {
foofoo
)
testtest(foofoo,/**/)
testtest(foofoo/**/)
testtest(
foofoo, fososos,/*
@@ -208,16 +210,16 @@ fun foo() {
testtest(testtest(foofoo)),
)
testtest(foofoo, testtest(testtest(foofoo, )), /**/testsa)
testtest(foofoo, testtest(testtest(foofoo)), /**/testsa)
testtest(foofoo, testtest(testtest(foofoo, ))/* */, /**/testsa)
testtest(foofoo, testtest(testtest(foofoo))/* */, /**/testsa)
testtest(foofoo, testtest(testtest(foofoo, ))/*
testtest(foofoo, testtest(testtest(foofoo))/*
*/, testsa)
testtest(foofoo, seee, testtest(testtest(foofoo, )), /**/testsa)
testtest(foofoo, seee, testtest(testtest(foofoo)), /**/testsa)
testtest(foofoo, seee, testtest(testtest(foofoo, )), /*
testtest(foofoo, seee, testtest(testtest(foofoo)), /*
*/testsa)
useCallable("B", "C", Callable {
@@ -265,9 +267,9 @@ fun foo() {
fun test() {
baz(
f = fun(it: Int): String = "$it" /*dwdwd
*/,
name = "" /*
*/,
f = fun(it: Int): String = "$it", /*dwdwd
*/
name = "", /*
*/
)
}
@@ -125,7 +125,7 @@ public abstract class AbstractFormatterTest extends KotlinLightIdeaTestCase {
}
public void doTestInvertedCallSite(@NotNull String expectedFileNameWithExtension) throws Exception {
doTest(expectedFileNameWithExtension, true, true);
doTest(expectedFileNameWithExtension, true, false);
}
public void doTestCallSite(@NotNull String expectedFileNameWithExtension) throws Exception {
@@ -138,7 +138,7 @@ public abstract class AbstractFormatterTest extends KotlinLightIdeaTestCase {
String originalFileText = FileUtil.loadFile(new File(testFileName + testFileExtension), true);
CodeStyleSettings codeStyleSettings = CodeStyle.getSettings(getProject_());
RegistryValue registryValue = Registry.get("kotlin.formatter.allowTrailingCommaOnCallSite");
KotlinCodeStyleSettings customSettings = codeStyleSettings.getCustomSettings(KotlinCodeStyleSettings.class);
try {
Integer rightMargin = InTextDirectivesUtils.getPrefixedInt(originalFileText, "// RIGHT_MARGIN: ");
if (rightMargin != null) {
@@ -147,7 +147,7 @@ public abstract class AbstractFormatterTest extends KotlinLightIdeaTestCase {
Boolean trailingComma = InTextDirectivesUtils.getPrefixedBoolean(originalFileText, "// TRAILING_COMMA: ");
if (trailingComma != null) {
codeStyleSettings.getCustomSettings(KotlinCodeStyleSettings.class).ALLOW_TRAILING_COMMA = trailingComma;
customSettings.ALLOW_TRAILING_COMMA = trailingComma;
}
SettingsConfigurator configurator = FormatSettingsUtil.createConfigurator(originalFileText, codeStyleSettings);
@@ -158,12 +158,11 @@ public abstract class AbstractFormatterTest extends KotlinLightIdeaTestCase {
configurator.configureInvertedSettings();
}
registryValue.setValue(callSite);
customSettings.ALLOW_TRAILING_COMMA_ON_CALL_SITE = callSite;
doTextTest(originalFileText, new File(expectedFileNameWithExtension), testFileExtension);
}
finally {
codeStyleSettings.clearCodeStyleSettings();
registryValue.resetToDefault();
}
}
}
@@ -1435,7 +1435,7 @@ class SmartEnterTest : KotlinLightCodeInsightFixtureTestCase() {
"""
fun foo(i: Int) = 1
fun test4() {
foo(1,<caret>)
foo(1<caret>)
}
"""
)