Collection<PsiAnnotation> (@NotNull PsiClass annClass, @NotNull SearchScope useScope, @NotNull Project project) { return ReadAction.compute(() -> { if (useScope instanceof GlobalSearchScope) { return JavaAnnotationIndex.getInstance().getAnnotations(annClass.getName(), project, (GlobalSearchScope)useScope); } List<PsiAnnotation> result = new ArrayList<>(); for (PsiElement element : ((LocalSearchScope)useScope).getScope()) { result.addAll(PsiTreeUtil.findChildrenOfType(element, PsiAnnotation.class)); } return result; }); }