1
1
package io .avaje .inject .generator ;
2
2
3
+ import javax .lang .model .element .AnnotationMirror ;
3
4
import javax .lang .model .element .Element ;
4
5
import javax .lang .model .element .ExecutableElement ;
5
6
import javax .lang .model .element .Modifier ;
@@ -34,9 +35,7 @@ final class TypeExtendsInjection {
34
35
this .baseType = baseType ;
35
36
this .context = context ;
36
37
this .factory = factory ;
37
-
38
- AspectAnnotationReader reader = new AspectAnnotationReader (context , baseType , baseType );
39
- this .typeAspects = reader .read ();
38
+ this .typeAspects = readAspects (baseType );
40
39
}
41
40
42
41
void read (TypeElement type ) {
@@ -55,6 +54,19 @@ void read(TypeElement type) {
55
54
}
56
55
}
57
56
57
+ /** Read the annotations on the type. */
58
+ List <AspectPair > readAspects (Element element ) {
59
+ final List <AspectPair > aspects = new ArrayList <>();
60
+ for (final AnnotationMirror annotationMirror : element .getAnnotationMirrors ()) {
61
+ final var anElement = annotationMirror .getAnnotationType ().asElement ();
62
+ final var aspect = AspectPrism .getInstanceOn (anElement );
63
+ if (aspect != null ) {
64
+ aspects .add (new AspectPair (anElement , aspect .ordering ()));
65
+ }
66
+ }
67
+ return aspects ;
68
+ }
69
+
58
70
private void readField (Element element ) {
59
71
InjectPrism inject = InjectPrism .getInstanceOn (element );
60
72
if (inject != null ) {
@@ -133,7 +145,7 @@ private void checkForAspect(ExecutableElement methodElement) {
133
145
return ;
134
146
}
135
147
int nameIndex = methodNameIndex (methodElement .getSimpleName ().toString ());
136
- List <AspectPair > aspectPairs = new AspectAnnotationReader ( context , baseType , methodElement ). read ( );
148
+ List <AspectPair > aspectPairs = readAspects ( methodElement );
137
149
aspectPairs .addAll (typeAspects );
138
150
139
151
if (!aspectPairs .isEmpty ()) {
0 commit comments