KT-21770 Pasting into an interpolated string shouldn't escape $
This commit is contained in:
committed by
Dmitry Jemerov
parent
eb25ac44e6
commit
a4fbe95112
@@ -177,7 +177,8 @@ private class TemplateTokenSequence(private val inputString: String) : Sequence<
|
|||||||
}
|
}
|
||||||
else if (this.length > 1 && this[0] == '$') {
|
else if (this.length > 1 && this[0] == '$') {
|
||||||
val guessedIdentifier = substring(1)
|
val guessedIdentifier = substring(1)
|
||||||
KotlinLexer().apply { start(guessedIdentifier) }.tokenType == KtTokens.IDENTIFIER
|
val tokenType = KotlinLexer().apply { start(guessedIdentifier) }.tokenType
|
||||||
|
tokenType == KtTokens.IDENTIFIER || tokenType == KtTokens.THIS_KEYWORD
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
false
|
false
|
||||||
@@ -190,7 +191,8 @@ private class TemplateTokenSequence(private val inputString: String) : Sequence<
|
|||||||
when (lexer.tokenType) {
|
when (lexer.tokenType) {
|
||||||
KtTokens.SHORT_TEMPLATE_ENTRY_START -> {
|
KtTokens.SHORT_TEMPLATE_ENTRY_START -> {
|
||||||
lexer.advance()
|
lexer.advance()
|
||||||
return if (lexer.tokenType == KtTokens.IDENTIFIER) {
|
val tokenType = lexer.tokenType
|
||||||
|
return if (tokenType == KtTokens.IDENTIFIER || tokenType == KtTokens.THIS_KEYWORD) {
|
||||||
from + lexer.tokenEnd - 1
|
from + lexer.tokenEnd - 1
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
class Bar() {
|
||||||
|
val a = "begin This is $this end"
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
class Foo() {
|
||||||
|
val a = "<selection>This is $this</selection>"
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
class Bar() {
|
||||||
|
val a = "begin <caret> end"
|
||||||
|
}
|
||||||
+6
@@ -54,6 +54,12 @@ public class LiteralKotlinToKotlinCopyPasteTestGenerated extends AbstractLiteral
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("DontEscapeThis.kt")
|
||||||
|
public void testDontEscapeThis() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/copyPaste/literal/DontEscapeThis.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("DontUnescapeLiteralWIthCode.kt")
|
@TestMetadata("DontUnescapeLiteralWIthCode.kt")
|
||||||
public void testDontUnescapeLiteralWIthCode() throws Exception {
|
public void testDontUnescapeLiteralWIthCode() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/copyPaste/literal/DontUnescapeLiteralWIthCode.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/copyPaste/literal/DontUnescapeLiteralWIthCode.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user