Minor improvement in convert to string template inspection: no highlighting when the expression is split onto multiple lines
This commit is contained in:
@@ -49,9 +49,10 @@ class ConvertToStringTemplateIntention : SelfTargetingOffsetIndependentIntention
|
||||
|
||||
fun shouldSuggestToConvert(expression: KtBinaryExpression): Boolean {
|
||||
val entries = buildReplacement(expression).entries
|
||||
return entries.none { it is KtBlockStringTemplateEntry } &&
|
||||
!entries.all { it is KtLiteralStringTemplateEntry || it is KtEscapeStringTemplateEntry }
|
||||
return entries.none { it is KtBlockStringTemplateEntry }
|
||||
&& !entries.all { it is KtLiteralStringTemplateEntry || it is KtEscapeStringTemplateEntry }
|
||||
&& entries.count { it is KtLiteralStringTemplateEntry } > 1
|
||||
&& !expression.textContains('\n')
|
||||
}
|
||||
|
||||
private fun isApplicableToNoParentCheck(expression: KtBinaryExpression): Boolean {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
fun foo(p: Int) {
|
||||
val v = <caret>"line 1\n" +
|
||||
"line 2: " + p + "\n" +
|
||||
"line 3"
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun foo(p: Int) {
|
||||
val v = "line 1\nline 2: $p\nline 3"
|
||||
}
|
||||
@@ -4795,6 +4795,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("onMultipleLines.kt")
|
||||
public void testOnMultipleLines() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertToStringTemplate/onMultipleLines.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("onlyForConcat.kt")
|
||||
public void testOnlyForConcat() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertToStringTemplate/onlyForConcat.kt");
|
||||
|
||||
Reference in New Issue
Block a user