Process '$' correctly in "Convert concatenation to template"
So #KT-12226 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
3b2bbee595
commit
66906e2c80
@@ -86,9 +86,10 @@ open class ConvertToStringTemplateIntention : SelfTargetingOffsetIndependentInte
|
|||||||
|
|
||||||
if (KotlinBuiltIns.isChar(type)) {
|
if (KotlinBuiltIns.isChar(type)) {
|
||||||
val value = expressionText.removePrefix("'").removeSuffix("'")
|
val value = expressionText.removePrefix("'").removeSuffix("'")
|
||||||
return when (value) { // escape double quote and unescape single one
|
return when (value) { // escape double quote and unescape single one and $
|
||||||
"\"" -> "\\\""
|
"\"" -> "\\\""
|
||||||
"\\'" -> "'"
|
"\\'" -> "'"
|
||||||
|
"$" -> if (forceBraces) "\\$" else "$"
|
||||||
else -> value
|
else -> value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun test(): String {
|
||||||
|
return "" + '$' + "foo" + '$' + "bar" + '$'<caret>
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun test(): String {
|
||||||
|
return "\$foo\$bar$"<caret>
|
||||||
|
}
|
||||||
@@ -6768,6 +6768,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("dollarSignChar.kt")
|
||||||
|
public void testDollarSignChar() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertToStringTemplate/dollarSignChar.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("endOfLineComment.kt")
|
@TestMetadata("endOfLineComment.kt")
|
||||||
public void testEndOfLineComment() throws Exception {
|
public void testEndOfLineComment() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertToStringTemplate/endOfLineComment.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertToStringTemplate/endOfLineComment.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user