mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
[java-completion] Resolve annotations inherited from any instance of java.lang.Annotation
If the project has 2+ JDKs, it's possible that we want to use an annotation from another module, which uses another JDK, so we won't be able to find it if we search inheritors of java.lang.Annotation defined in our JDK only Fixes IDEA-362050 Annotation auto-complete is broken for some classes from other modules (cherry picked from commit 3133dce302d9dfd03e169678c00fb4d0e23dd50b) IJ-CR-151470 GitOrigin-RevId: 9f67471bcb07f2da5717414466832c5630414fd2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f910392d5d
commit
b6fd54065e
@@ -213,8 +213,10 @@ public class JavaClassNameCompletionContributor extends CompletionContributor im
|
||||
private static @NotNull MultiMap<String, PsiClass> getAllAnnotationClasses(PsiElement context, PrefixMatcher matcher) {
|
||||
MultiMap<String, PsiClass> map = new MultiMap<>();
|
||||
GlobalSearchScope scope = context.getResolveScope();
|
||||
PsiClass annotation = JavaPsiFacade.getInstance(context.getProject()).findClass(CommonClassNames.JAVA_LANG_ANNOTATION_ANNOTATION, scope);
|
||||
if (annotation != null) {
|
||||
Project project = context.getProject();
|
||||
PsiClass[] annotations = JavaPsiFacade.getInstance(project).findClasses(
|
||||
CommonClassNames.JAVA_LANG_ANNOTATION_ANNOTATION, GlobalSearchScope.allScope(project));
|
||||
for (PsiClass annotation : annotations) {
|
||||
DirectClassInheritorsSearch.search(annotation, scope, false).forEach(psiClass -> {
|
||||
if (!psiClass.isAnnotationType() || psiClass.getQualifiedName() == null) return true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user