11package io .avaje .inject .generator ;
22
3+ import javax .lang .model .element .AnnotationMirror ;
34import javax .lang .model .element .Element ;
45import javax .lang .model .element .ExecutableElement ;
56import javax .lang .model .element .Modifier ;
@@ -34,9 +35,7 @@ final class TypeExtendsInjection {
3435 this .baseType = baseType ;
3536 this .context = context ;
3637 this .factory = factory ;
37-
38- AspectAnnotationReader reader = new AspectAnnotationReader (context , baseType , baseType );
39- this .typeAspects = reader .read ();
38+ this .typeAspects = readAspects (baseType );
4039 }
4140
4241 void read (TypeElement type ) {
@@ -55,6 +54,19 @@ void read(TypeElement type) {
5554 }
5655 }
5756
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+
5870 private void readField (Element element ) {
5971 InjectPrism inject = InjectPrism .getInstanceOn (element );
6072 if (inject != null ) {
@@ -133,7 +145,7 @@ private void checkForAspect(ExecutableElement methodElement) {
133145 return ;
134146 }
135147 int nameIndex = methodNameIndex (methodElement .getSimpleName ().toString ());
136- List <AspectPair > aspectPairs = new AspectAnnotationReader ( context , baseType , methodElement ). read ( );
148+ List <AspectPair > aspectPairs = readAspects ( methodElement );
137149 aspectPairs .addAll (typeAspects );
138150
139151 if (!aspectPairs .isEmpty ()) {
0 commit comments