Surround with braces when completing backing field in string template

This commit is contained in:
Valentin Kipyatkov
2015-03-06 16:12:12 +03:00
parent 620fb8683b
commit de7b4dc681
4 changed files with 31 additions and 2 deletions
@@ -118,9 +118,12 @@ class LookupElementsCollector(
}
if (descriptor is PropertyDescriptor) {
val lookupElement = lookupElementFactory.createBackingFieldLookupElement(descriptor, inDescriptor, resolutionFacade)
var lookupElement = lookupElementFactory.createBackingFieldLookupElement(descriptor, inDescriptor, resolutionFacade)
if (lookupElement != null) {
addElement(lookupElement)
if (surroundCallsWithBraces) {
lookupElement = lookupElement!!.withBracesSurrounding()
}
addElement(lookupElement!!)
}
}
}
@@ -0,0 +1,10 @@
class C {
var property = "abc"
get() = $property + 1
fun foo(){
"$<caret>"
}
}
// ELEMENT: $property
@@ -0,0 +1,10 @@
class C {
var property = "abc"
get() = $property + 1
fun foo(){
"${$property<caret>}"
}
}
// ELEMENT: $property
@@ -113,6 +113,12 @@ public class BasicCompletionHandlerTestGenerated extends AbstractBasicCompletion
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/completion/handlers/basic/stringTemplate"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("BackingField.kt")
public void testBackingField() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/handlers/basic/stringTemplate/BackingField.kt");
doTest(fileName);
}
@TestMetadata("NotEmptyPrefix.kt")
public void testNotEmptyPrefix() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/handlers/basic/stringTemplate/NotEmptyPrefix.kt");