KT-11912 String interpolation is not converted to ${} form when accessing this.property

#KT-11912 Fixed
This commit is contained in:
Valentin Kipyatkov
2016-04-18 17:28:39 +03:00
parent e441f0509f
commit f3bb3e9c6e
4 changed files with 19 additions and 2 deletions
@@ -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?)"
@@ -0,0 +1,6 @@
fun String.foo() {
val s = "${this.equals(<caret>)}"
}
// ELEMENT: equals
// TAIL_TEXT: "(other: Any?)"
@@ -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);
}