Set<String> (String annotationClassName) { GlobalSearchScope allScope = GlobalSearchScope.allScope(myProject); // todo use allScope once Kotlin support becomes fast enough (https://youtrack.jetbrains.com/issue/KT-13734) GlobalSearchScope usageScope = GlobalSearchScope.getScopeRestrictedByFileTypes(allScope, JavaFileType.INSTANCE); Set<String> result = new HashSet<>(); List<PsiClass> annoClasses = new ArrayList<>(List.of(JavaPsiFacade.getInstance(myProject).findClasses(annotationClassName, allScope))); for (int cursor = 0; cursor < annoClasses.size(); cursor++) { Parameters parameters = new Parameters(annoClasses.get(cursor), usageScope, true, PsiClass.class, PsiParameter.class, PsiMethod.class, PsiRecordComponent.class); AnnotatedElementsSearch.searchElements(parameters).forEach(element -> { if (element instanceof PsiParameter psiParameter) { final PsiElement scope = psiParameter.getDeclarationScope(); if (scope instanceof PsiMethod psiMethod) { ContainerUtil.addIfNotNull(result, psiMethod.getName()); } } else if (element instanceof PsiClass psiClass && psiClass.isAnnotationType() && !annoClasses.contains(psiClass)) { annoClasses.add(psiClass); } else if (element instanceof PsiMethod psiMethod) { ContainerUtil.addIfNotNull(result, psiMethod.getName()); } else if (element instanceof PsiRecordComponent psiRecordComponent) { final PsiClass psiClass = psiRecordComponent.getContainingClass(); if (psiClass != null) { ContainerUtil.addIfNotNull(result, psiClass.getName()); } } return true; }); } return result; }