public static boolean processImplicitImports( @NotNull PsiScopeProcessor processor, ResolveState state, PsiElement lastParent, PsiElement place, @NotNull GroovyFile file) { JavaPsiFacade facade = JavaPsiFacade.getInstance(file.getProject()); final DelegatingScopeProcessor packageSkipper = new DelegatingScopeProcessor(processor) { @Override public boolean execute(@NotNull PsiElement element, ResolveState state) { if (element instanceof PsiPackage) return true; return super.execute(element, state); } }; for (final String implicitlyImported : getImplicitlyImportedPackages(file)) { PsiPackage aPackage = facade.findPackage(implicitlyImported); if (aPackage == null) continue; if (!aPackage.processDeclarations(packageSkipper, state, lastParent, place)) { return false; } } GroovyPsiManager groovyPsiManager = GroovyPsiManager.getInstance(file.getProject()); for (String implicitlyImportedClass : GroovyFileBase.IMPLICITLY_IMPORTED_CLASSES) { PsiClass clazz = groovyPsiManager.findClassWithCache(implicitlyImportedClass, file.getResolveScope()); if (clazz != null && !ResolveUtil.processElement(processor, clazz, state)) return false; } return true; }
private boolean processDeclarationsForMultipleElements( @NotNull final PsiScopeProcessor processor, @Nullable PsiElement lastParent, @NotNull PsiElement place, @NotNull ResolveState state) { GrCodeReferenceElement ref = getImportReference(); if (ref == null) return true; if (isStatic()) { final PsiElement resolved = ref.resolve(); if (resolved instanceof PsiClass) { state = state.put(ClassHint.RESOLVE_CONTEXT, this); final PsiClass clazz = (PsiClass) resolved; for (final PsiScopeProcessor each : GroovyResolverProcessor.allProcessors(processor)) { if (!clazz.processDeclarations( new DelegatingScopeProcessor(each) { @Override public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { if (element instanceof PsiMember && ((PsiMember) element).hasModifierProperty(PsiModifier.STATIC)) { return super.execute(element, state); } return true; } }, state, lastParent, place)) return false; } } } else { if (ResolveUtil.shouldProcessClasses(processor.getHint(ElementClassHint.KEY))) { String qName = PsiUtil.getQualifiedReferenceText(ref); if (qName != null) { PsiPackage aPackage = JavaPsiFacade.getInstance(getProject()).findPackage(qName); if (aPackage != null && !((GroovyFile) getContainingFile()) .getPackageName() .equals(aPackage.getQualifiedName())) { state = state.put(ClassHint.RESOLVE_CONTEXT, this); if (!aPackage.processDeclarations(processor, state, lastParent, place)) return false; } } } } return true; }