@NotNull private GroovyResolveResult[] resolveTypeOrProperty() { if (isDefinitelyKeyOfMap()) return GroovyResolveResult.EMPTY_ARRAY; final GroovyResolveResult[] results = resolveTypeOrPropertyInner(); if (results.length == 0) return GroovyResolveResult.EMPTY_ARRAY; if (!ResolveUtil.mayBeKeyOfMap(this)) return results; // filter out all members from super classes. We should return only accessible members from map // classes List<GroovyResolveResult> filtered = new ArrayList<GroovyResolveResult>(); for (GroovyResolveResult result : results) { final PsiElement element = result.getElement(); if (element instanceof PsiMember) { if (((PsiMember) element).hasModifierProperty(PsiModifier.PRIVATE)) continue; final PsiClass containingClass = ((PsiMember) element).getContainingClass(); if (containingClass != null) { if (!InheritanceUtil.isInheritor(containingClass, CommonClassNames.JAVA_UTIL_MAP)) continue; final String name = containingClass.getQualifiedName(); if (name != null && name.startsWith("java.")) continue; if (containingClass.getLanguage() != GroovyLanguage.INSTANCE && !InheritanceUtil.isInheritor( containingClass, GroovyCommonClassNames.DEFAULT_BASE_CLASS_NAME)) { continue; } } } filtered.add(result); } return ContainerUtil.toArray(filtered, new GroovyResolveResult[filtered.size()]); }
@NotNull private static GroovyResolveResult[] collapseReflectedMethods(GroovyResolveResult[] candidates) { Set<GrMethod> visited = ContainerUtil.newHashSet(); List<GroovyResolveResult> collapsed = ContainerUtil.newArrayList(); for (GroovyResolveResult result : candidates) { PsiElement element = result.getElement(); if (element instanceof GrReflectedMethod) { GrMethod baseMethod = ((GrReflectedMethod) element).getBaseMethod(); if (visited.add(baseMethod)) { collapsed.add( PsiImplUtil.reflectedToBase(result, baseMethod, (GrReflectedMethod) element)); } } else { collapsed.add(result); } } return collapsed.toArray(new GroovyResolveResult[collapsed.size()]); }