mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
don't suggest the same imported class in groovy twice
This commit is contained in:
+8
-3
@@ -228,14 +228,15 @@ public class GroovyCompletionUtil {
|
||||
if (importedName != null) {
|
||||
final GrCodeReferenceElement importReference = ((GrImportStatement)context).getImportReference();
|
||||
if (importReference != null) {
|
||||
boolean alias = ((GrImportStatement)context).isAliasedImport();
|
||||
for (GroovyResolveResult r : importReference.multiResolve(false)) {
|
||||
final PsiElement resolved = r.getElement();
|
||||
if (context.getManager().areElementsEquivalent(resolved, element)) {
|
||||
return generateLookupForImportedElement(candidate, importedName);
|
||||
return generateLookupForImportedElement(candidate, importedName, alias);
|
||||
}
|
||||
else {
|
||||
if (resolved instanceof PsiField && element instanceof PsiMethod && isAccessorFor((PsiMethod)element, (PsiField)resolved)) {
|
||||
return generateLookupForImportedElement(candidate, getAccessorPrefix((PsiMethod)element) + capitalize(importedName));
|
||||
return generateLookupForImportedElement(candidate, getAccessorPrefix((PsiMethod)element) + capitalize(importedName), alias);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -268,9 +269,13 @@ public class GroovyCompletionUtil {
|
||||
return AllClassesGetter.createLookupItem(psiClass, new GroovyClassNameInsertHandler());
|
||||
}
|
||||
|
||||
private static LookupElementBuilder generateLookupForImportedElement(GroovyResolveResult resolveResult, String importedName) {
|
||||
private static LookupElement generateLookupForImportedElement(GroovyResolveResult resolveResult, String importedName, boolean alias) {
|
||||
final PsiElement element = resolveResult.getElement();
|
||||
assert element != null;
|
||||
if (!alias && element instanceof PsiClass) {
|
||||
return createClassLookupItem((PsiClass)element);
|
||||
}
|
||||
|
||||
final PsiSubstitutor substitutor = resolveResult.getSubstitutor();
|
||||
LookupElementBuilder builder = LookupElementBuilder.create(resolveResult, importedName).setPresentableText(importedName);
|
||||
return setupLookupBuilder(element, substitutor, builder);
|
||||
|
||||
+7
-1
@@ -239,7 +239,6 @@ new Fxoo()<caret>\n"""
|
||||
myFixture.configureByText("a.groovy", "new ArrayLi<caret>\n")
|
||||
myFixture.completeBasic()
|
||||
myFixture.checkResult "new ArrayList(<caret>)\n"
|
||||
|
||||
}
|
||||
|
||||
public void testOnlyAnnotationsAfterAt() {
|
||||
@@ -262,5 +261,12 @@ new Fxoo()<caret>\n"""
|
||||
myFixture.checkResult 'def s = """a\njava.lang.ArrayIndexOutOfBoundsException<caret>\na"""'
|
||||
}
|
||||
|
||||
public void testDoubleClass() {
|
||||
myFixture.addClass "package foo; public class Zooooooo {}"
|
||||
myFixture.configureByText("a.groovy", """import foo.Zooooooo
|
||||
Zoooo<caret>x""")
|
||||
assertOneElement(myFixture.completeBasic())
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user