[groovy] consider keywords as valid parts of fqn while adjusting references (IDEA-134006)

This commit is contained in:
Daniil Ovchinnikov
2016-09-20 21:42:29 +03:00
parent 43cb44579a
commit fa59931495
2 changed files with 33 additions and 2 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -964,7 +964,9 @@ public class PsiImplUtil {
while (expr instanceof GrReferenceExpression) {
final PsiElement nameElement = ((GrReferenceExpression)expr).getReferenceNameElement();
if (((GrReferenceExpression)expr).getTypeArguments().length > 0) return false;
if (nameElement == null || nameElement.getNode().getElementType() != GroovyTokenTypes.mIDENT) return false;
if (nameElement == null || !TokenSets.CODE_REFERENCE_ELEMENT_NAME_TOKENS.contains(nameElement.getNode().getElementType())) {
return false;
}
IElementType dotType = ((GrReferenceExpression)expr).getDotTokenType();
if (dotType != null && dotType != GroovyTokenTypes.mDOT) return false;
expr = ((GrReferenceExpression)expr).getQualifierExpression();
@@ -316,4 +316,33 @@ print new Upper.Inner()
''')
}
void "test complete class within 'in' package"() {
myFixture.with {
addClass '''\
package in.foo.com;
public class Foooo {}
'''
configureByText '_.groovy', 'Fooo<caret>'
complete CompletionType.BASIC
type '\n'
checkResult '''import in.foo.com.Foooo
Foooo<caret>'''
}
}
void "test complete class within 'def' package"() {
myFixture.with {
addClass '''\
package def.foo.com;
public class Foooo {}
'''
configureByText '_.groovy', 'Fooo<caret>'
complete CompletionType.BASIC
type '\n'
checkResult '''import def.foo.com.Foooo
Foooo<caret>'''
}
}
}