List<PsiModifierListOwner> (final PsiClass clazz, final GlobalSearchScope scope) { final String name = ReadAction.compute(() -> clazz.getName()); if (name == null) return Collections.emptyList(); final Collection<PsiElement> members = ReadAction .compute(() -> StubIndex.getElements(GrAnnotatedMemberIndex.KEY, name, clazz.getProject(), scope, PsiElement.class)); if (members.isEmpty()) { return Collections.emptyList(); } final List<PsiModifierListOwner> result = new ArrayList<>(); for (final PsiElement element : members) { ApplicationManager.getApplication().runReadAction(() -> { PsiElement e = element instanceof GroovyFile ? ((GroovyFile)element).getPackageDefinition() : element; if (e instanceof PsiModifierListOwner) { result.add((PsiModifierListOwner)e); } }); } return result; }