Formatter: don't format elvis operator in string template
#KT-34049 Fixed
This commit is contained in:
committed by
Dmitry Gridin
parent
bcee8ce04b
commit
d75b938089
@@ -612,7 +612,7 @@ abstract class KotlinCommonBlock(
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nodePsi.operationToken == ELVIS) {
|
||||
if (nodePsi.operationToken == ELVIS && nodePsi.getStrictParentOfType<KtStringTemplateExpression>() == null) {
|
||||
return { childElement ->
|
||||
if (childElement.elementType == OPERATION_REFERENCE) {
|
||||
Wrap.createWrap(settings.kotlinCustomSettings.WRAP_ELVIS_EXPRESSIONS, true)
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
fun test() {
|
||||
val projectExtId: String? = "id"
|
||||
val s = "https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:${projectExtId ?: "Kotlin_dev_Compiler"})"
|
||||
}
|
||||
|
||||
// SET_INT: WRAP_ELVIS_EXPRESSIONS = 2
|
||||
@@ -0,0 +1,6 @@
|
||||
fun test() {
|
||||
val projectExtId: String? = "id"
|
||||
val s = "https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:${projectExtId ?: "Kotlin_dev_Compiler"})"
|
||||
}
|
||||
|
||||
// SET_INT: WRAP_ELVIS_EXPRESSIONS = 2
|
||||
@@ -235,6 +235,11 @@ public class FormatterTestGenerated extends AbstractFormatterTest {
|
||||
runTest("idea/testData/formatter/ElvisContinuationIndentOptions.after.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ElvisInStringTemplate.after.kt")
|
||||
public void testElvisInStringTemplate() throws Exception {
|
||||
runTest("idea/testData/formatter/ElvisInStringTemplate.after.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ElvisIndent.after.kt")
|
||||
public void testElvisIndent() throws Exception {
|
||||
runTest("idea/testData/formatter/ElvisIndent.after.kt");
|
||||
|
||||
Reference in New Issue
Block a user