|
23 | 23 | import org.eclipse.jdt.core.dom.Block; |
24 | 24 | import org.eclipse.jdt.core.dom.CompilationUnit; |
25 | 25 | import org.eclipse.jdt.core.dom.FieldAccess; |
26 | | -import org.eclipse.jdt.core.dom.IAnnotationBinding; |
27 | 26 | import org.eclipse.jdt.core.dom.ITypeBinding; |
28 | 27 | import org.eclipse.jdt.core.dom.SimpleName; |
29 | 28 | import org.eclipse.jdt.core.dom.ThisExpression; |
|
32 | 31 | import org.slf4j.Logger; |
33 | 32 | import org.slf4j.LoggerFactory; |
34 | 33 | import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex; |
| 34 | +import org.springframework.ide.vscode.boot.java.Annotations; |
| 35 | +import org.springframework.ide.vscode.boot.java.annotations.AnnotationHierarchies; |
35 | 36 | import org.springframework.ide.vscode.boot.java.handlers.CompletionProvider; |
36 | 37 | import org.springframework.ide.vscode.boot.java.rewrite.RewriteRefactorings; |
37 | 38 | import org.springframework.ide.vscode.commons.java.IJavaProject; |
@@ -92,7 +93,8 @@ public void provideCompletions(ASTNode node, int offset, TextDocument doc, |
92 | 93 | node = fa.getName(); |
93 | 94 | } |
94 | 95 |
|
95 | | - if (isSpringComponent(topLevelClass)) { |
| 96 | + |
| 97 | + if (AnnotationHierarchies.get(node).isAnnotatedWith(topLevelClass.resolveBinding(), Annotations.COMPONENT)) { |
96 | 98 | String className = getFullyQualifiedName(topLevelClass); |
97 | 99 | Bean[] beans = this.springIndex.getBeansOfProject(project.getElementName()); |
98 | 100 | ITypeBinding topLevelBeanType = topLevelClass.resolveBinding(); |
@@ -133,28 +135,6 @@ public void provideCompletions(ASTNode node, int offset, TextDocument doc, |
133 | 135 | } |
134 | 136 | } |
135 | 137 |
|
136 | | - private static boolean isSpringComponent(TypeDeclaration node) { |
137 | | - for (IAnnotationBinding annotation : node.resolveBinding().getAnnotations()) { |
138 | | - if (isSpringComponentAnnotation(annotation)) { |
139 | | - return true; |
140 | | - } |
141 | | - } |
142 | | - return false; |
143 | | - } |
144 | | - |
145 | | - private static boolean isSpringComponentAnnotation(IAnnotationBinding annotation) { |
146 | | - String annotationName = annotation.getAnnotationType().getQualifiedName(); |
147 | | - if (annotationName.equals("org.springframework.stereotype.Component")) { |
148 | | - return true; |
149 | | - } |
150 | | - for (IAnnotationBinding metaAnnotation : annotation.getAnnotationType().getAnnotations()) { |
151 | | - if (metaAnnotation.getAnnotationType().getQualifiedName().equals("org.springframework.stereotype.Component")) { |
152 | | - return true; |
153 | | - } |
154 | | - } |
155 | | - return false; |
156 | | - } |
157 | | - |
158 | 138 | private static TypeDeclaration findParentClass(ASTNode node) { |
159 | 139 | ASTNode current = node; |
160 | 140 | while (current != null) { |
|
0 commit comments