IDEA-110369 Autocompletion in GString with two extrapolated strings - $ is deleted

This commit is contained in:
Max Medvedev
2013-07-12 18:58:36 +04:00
parent 74186f0592
commit f1dc3f2d87
2 changed files with 38 additions and 0 deletions
@@ -659,6 +659,12 @@ public class GroovyCompletionContributor extends CompletionContributor {
if (identifier != null) {
context.setDummyIdentifier(identifier);
}
//don't eat $ from gstrings when completing previous injection ref. see IDEA-110369
PsiElement position = context.getFile().findElementAt(context.getStartOffset());
if (position!= null && position.getNode().getElementType() == mDOLLAR) {
context.getOffsetMap().addOffset(CompletionInitializationContext.IDENTIFIER_END_OFFSET, context.getStartOffset());
}
}
private String getIdentifier(CompletionInitializationContext context) {
@@ -1823,4 +1823,36 @@ def foo(Util util) {
}
''', CompletionType.SMART)
}
void testDollarInGString() {
doCompletionTest('''\
class Autocompletion {
def reportDir = '/'
def reportDirectory = '/'
def fileName = "$reportD<caret>${File.separator}"
}
''', '''\
class Autocompletion {
def reportDir = '/'
def reportDirectory = '/'
def fileName = "$reportDir<caret>${File.separator}"
}
''', '\t', CompletionType.BASIC)
}
void testDollarInGString2() {
doCompletionTest('''\
class Autocompletion {
def reportDir = '/'
def fileName = "$report<caret>D${File.separator}"
}
''', '''\
class Autocompletion {
def reportDir = '/'
def fileName = "$reportDir<caret>${File.separator}"
}
''', '\t', CompletionType.BASIC)
}
}