Formatter: fix line break before OperationReference in elvis
#KT-22362 Fixed
This commit is contained in:
@@ -615,7 +615,7 @@ abstract class KotlinCommonBlock(
|
||||
}
|
||||
if (nodePsi.operationToken == ELVIS && nodePsi.getStrictParentOfType<KtStringTemplateExpression>() == null) {
|
||||
return { childElement ->
|
||||
if (childElement.elementType == OPERATION_REFERENCE) {
|
||||
if (childElement.elementType == OPERATION_REFERENCE && (childElement.psi as? KtOperationReferenceExpression)?.operationSignTokenType == ELVIS) {
|
||||
Wrap.createWrap(settings.kotlinCustomSettings.WRAP_ELVIS_EXPRESSIONS, true)
|
||||
} else {
|
||||
null
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
infix fun String.concat(other: String): String = this
|
||||
fun binaryContext(anchor: String?) {
|
||||
val v1 = "1234567890... add many chars ...1234567890" concat "b"
|
||||
val v2 = anchor
|
||||
?: "1234567890... add many chars ...1234567890" concat "b"
|
||||
val v3 = anchor
|
||||
?: "1234567890... add many chars ...1234567890" concat "1234567890... add many chars ...1234567890" concat "1234567890... add many chars ...1234567890" concat "b"
|
||||
}
|
||||
|
||||
// SET_INT: WRAP_ELVIS_EXPRESSIONS = 2
|
||||
@@ -0,0 +1,8 @@
|
||||
infix fun String.concat(other: String): String = this
|
||||
fun binaryContext(anchor: String?) {
|
||||
val v1 = "1234567890... add many chars ...1234567890" concat "b"
|
||||
val v2 = anchor ?: "1234567890... add many chars ...1234567890" concat "b"
|
||||
val v3 = anchor ?: "1234567890... add many chars ...1234567890" concat "1234567890... add many chars ...1234567890" concat "1234567890... add many chars ...1234567890" concat "b"
|
||||
}
|
||||
|
||||
// SET_INT: WRAP_ELVIS_EXPRESSIONS = 2
|
||||
@@ -245,6 +245,11 @@ public class FormatterTestGenerated extends AbstractFormatterTest {
|
||||
runTest("idea/testData/formatter/ElvisIndent.after.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ElvisWithOperationReference.after.kt")
|
||||
public void testElvisWithOperationReference() throws Exception {
|
||||
runTest("idea/testData/formatter/ElvisWithOperationReference.after.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ElvisWrap.after.kt")
|
||||
public void testElvisWrap() throws Exception {
|
||||
runTest("idea/testData/formatter/ElvisWrap.after.kt");
|
||||
|
||||
Reference in New Issue
Block a user