From bbc7bc631a1d92176a0d4ee363a3100f6002baca Mon Sep 17 00:00:00 2001 From: Dusan Balek Date: Tue, 30 Nov 2021 13:14:24 +0100 Subject: [PATCH] Micronaut Data Finder completion ceck for @Repository annotation fixed. --- .../completion/MicronautDataCompletionTask.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/enterprise/micronaut/src/org/netbeans/modules/micronaut/completion/MicronautDataCompletionTask.java b/enterprise/micronaut/src/org/netbeans/modules/micronaut/completion/MicronautDataCompletionTask.java index e02539449d96..4bfda64ed2cf 100644 --- a/enterprise/micronaut/src/org/netbeans/modules/micronaut/completion/MicronautDataCompletionTask.java +++ b/enterprise/micronaut/src/org/netbeans/modules/micronaut/completion/MicronautDataCompletionTask.java @@ -28,6 +28,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.Map; @@ -256,7 +257,7 @@ private void addComposeAndOrderCompletions(Map prop2Types, Strin private static TypeElement getEntityFor(CompilationInfo info, TreePath path) { TypeElement te = (TypeElement) info.getTrees().getElement(path); if (te.getModifiers().contains(Modifier.ABSTRACT)) { - if (checkForRepositoryAnnotation(te.getAnnotationMirrors())) { + if (checkForRepositoryAnnotation(te.getAnnotationMirrors(), new HashSet<>())) { Types types = info.getTypes(); TypeMirror repositoryType = types.erasure(info.getElements().getTypeElement(REPOSITORY_TYPE_NAME).asType()); for (TypeMirror iface : te.getInterfaces()) { @@ -275,10 +276,10 @@ private static TypeElement getEntityFor(CompilationInfo info, TreePath path) { return null; } - private static boolean checkForRepositoryAnnotation(List annotations) { + private static boolean checkForRepositoryAnnotation(List annotations, HashSet checked) { for (AnnotationMirror annotation : annotations) { - DeclaredType annotationType = annotation.getAnnotationType(); - if (REPOSITORY_ANNOTATION_NAME.contentEquals(((TypeElement) annotationType.asElement()).getQualifiedName()) || checkForRepositoryAnnotation(annotationType.getAnnotationMirrors())) { + TypeElement annotationElement = (TypeElement) annotation.getAnnotationType().asElement(); + if (REPOSITORY_ANNOTATION_NAME.contentEquals(annotationElement.getQualifiedName()) || checked.add(annotationElement) && checkForRepositoryAnnotation(annotationElement.getAnnotationMirrors(), checked)) { return true; } }