KT-11912 String interpolation is not converted to ${} form when accessing this.property
#KT-11912 Fixed
This commit is contained in:
+1
-2
@@ -343,9 +343,8 @@ class KotlinCompletionContributor : CompletionContributor() {
|
||||
|
||||
assert(startOffset > 1 && document.charsSequence[startOffset - 1] == '.')
|
||||
val token = context.file.findElementAt(startOffset - 2)!!
|
||||
assert(token.node.elementType == KtTokens.IDENTIFIER)
|
||||
assert(token.node.elementType == KtTokens.IDENTIFIER || token.node.elementType == KtTokens.THIS_KEYWORD)
|
||||
val nameRef = token.parent as KtNameReferenceExpression
|
||||
assert(nameRef.parent is KtSimpleNameStringTemplateEntry)
|
||||
|
||||
document.insertString(nameRef.startOffset, "{")
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
fun String.foo() {
|
||||
val s = "$this.<caret>"
|
||||
}
|
||||
|
||||
// ELEMENT: equals
|
||||
// TAIL_TEXT: "(other: Any?)"
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
fun String.foo() {
|
||||
val s = "${this.equals(<caret>)}"
|
||||
}
|
||||
|
||||
// ELEMENT: equals
|
||||
// TAIL_TEXT: "(other: Any?)"
|
||||
+6
@@ -672,6 +672,12 @@ public class BasicCompletionHandlerTestGenerated extends AbstractBasicCompletion
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("AfterThisDot.kt")
|
||||
public void testAfterThisDot() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/stringTemplate/AfterThisDot.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInStringTemplate() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/idea-completion/testData/handlers/basic/stringTemplate"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user