boolean (@NotNull final AnnotatedElementsSearch.Parameters p, @NotNull final Processor<? super PsiModifierListOwner> consumer) { final PsiClass annClass = p.getAnnotationClass(); assert annClass.isAnnotationType() : "Annotation type should be passed to annotated members search"; final String annotationFQN = ReadAction.compute(() -> annClass.getQualifiedName()); assert annotationFQN != null; final SearchScope scope = p.getScope(); final List<PsiModifierListOwner> candidates; if (scope instanceof GlobalSearchScope) { candidates = getAnnotatedMemberCandidates(annClass, ((GlobalSearchScope)scope)); } else { candidates = new ArrayList<>(); for (final PsiElement element : ((LocalSearchScope)scope).getScope()) { ApplicationManager.getApplication().runReadAction(() -> { if (element instanceof GroovyPsiElement) { ((GroovyPsiElement)element).accept(new GroovyRecursiveElementVisitor() { @Override public void visitMethod(@NotNull GrMethod method) { candidates.add(method); } @Override public void visitField(@NotNull GrField field) { candidates.add(field); } }); } }); } } for (final PsiModifierListOwner candidate : candidates) { boolean accepted = ReadAction.compute(() -> { if (AnnotatedElementsSearcher.isInstanceof(candidate, p.getTypes())) { PsiModifierList list = candidate.getModifierList(); if (list instanceof GrModifierList) { for (PsiAnnotation annotation : ((GrModifierList)list).getRawAnnotations()) { if ((p.isApproximate() || annotation.hasQualifiedName(annotationFQN)) && !consumer.process(candidate)) { return false; } } } } return true; }); if (!accepted) return false; } return true; }