Commit e7078f24 authored by peter's avatar peter
Browse files

don't create class lookup element for noname classes (EA-41335)

parent 0e906a07
Branches unavailable Tags unavailable
No related merge requests found
Showing with 22 additions and 19 deletions
+22 -19
......@@ -28,6 +28,7 @@ import com.intellij.psi.impl.DebugUtil;
import com.intellij.psi.impl.source.PostprocessReformattingAspect;
import com.intellij.psi.impl.source.PsiClassReferenceType;
import com.intellij.psi.util.PsiUtil;
import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
......@@ -213,27 +214,29 @@ public class PsiTypeLookupItem extends LookupItem {
final PsiClass psiClass = classResolveResult.getElement();
if (psiClass != null) {
final PsiSubstitutor substitutor = classResolveResult.getSubstitutor();
PsiClass resolved = JavaPsiFacade.getInstance(psiClass.getProject()).getResolveHelper().resolveReferencedClass(psiClass.getName(), context);
Set<String> allStrings = new HashSet<String>();
String lookupString = psiClass.getName();
allStrings.add(lookupString);
if (!psiClass.getManager().areElementsEquivalent(resolved, psiClass) && !PsiUtil.isInnerClass(psiClass)) {
// inner class name should be shown qualified if its not accessible by single name
PsiClass aClass = psiClass.getContainingClass();
while (aClass != null && !PsiUtil.isInnerClass(aClass)) {
lookupString = aClass.getName() + '.' + lookupString;
allStrings.add(lookupString);
aClass = aClass.getContainingClass();
String name = psiClass.getName();
if (name != null) {
final PsiSubstitutor substitutor = classResolveResult.getSubstitutor();
PsiClass resolved = JavaPsiFacade.getInstance(psiClass.getProject()).getResolveHelper().resolveReferencedClass(name, context);
Set<String> allStrings = new HashSet<String>();
allStrings.add(name);
if (!psiClass.getManager().areElementsEquivalent(resolved, psiClass) && !PsiUtil.isInnerClass(psiClass)) {
// inner class name should be shown qualified if its not accessible by single name
PsiClass aClass = psiClass.getContainingClass();
while (aClass != null && !PsiUtil.isInnerClass(aClass)) {
name = aClass.getName() + '.' + name;
allStrings.add(name);
aClass = aClass.getContainingClass();
}
}
}
PsiTypeLookupItem item = new PsiTypeLookupItem(psiClass, lookupString, diamond, bracketsCount, importFixer);
item.addLookupStrings(allStrings.toArray(new String[allStrings.size()]));
item.setAttribute(SUBSTITUTOR, substitutor);
return item;
PsiTypeLookupItem item = new PsiTypeLookupItem(psiClass, name, diamond, bracketsCount, importFixer);
item.addLookupStrings(ArrayUtil.toStringArray(allStrings));
item.setAttribute(SUBSTITUTOR, substitutor);
return item;
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment