Skip to content

Prisms 1.3/Turn Aspect Reader into a method #279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions inject-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-prisms</artifactId>
<version>1.1</version>
<version>1.3</version>
<optional>true</optional>
<scope>provided</scope>
</dependency>
Expand Down Expand Up @@ -55,7 +55,7 @@
<path>
<groupId>io.avaje</groupId>
<artifactId>avaje-prisms</artifactId>
<version>1.1</version>
<version>1.3</version>
</path>
</annotationProcessorPaths>
</configuration>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.avaje.inject.generator;

import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.Modifier;
Expand Down Expand Up @@ -34,9 +35,7 @@ final class TypeExtendsInjection {
this.baseType = baseType;
this.context = context;
this.factory = factory;

AspectAnnotationReader reader = new AspectAnnotationReader(context, baseType, baseType);
this.typeAspects = reader.read();
this.typeAspects = readAspects(baseType);
}

void read(TypeElement type) {
Expand All @@ -55,6 +54,19 @@ void read(TypeElement type) {
}
}

/** Read the annotations on the type. */
List<AspectPair> readAspects(Element element) {
final List<AspectPair> aspects = new ArrayList<>();
for (final AnnotationMirror annotationMirror : element.getAnnotationMirrors()) {
final var anElement = annotationMirror.getAnnotationType().asElement();
final var aspect = AspectPrism.getInstanceOn(anElement);
if (aspect != null) {
aspects.add(new AspectPair(anElement, aspect.ordering()));
}
}
return aspects;
}

private void readField(Element element) {
InjectPrism inject = InjectPrism.getInstanceOn(element);
if (inject != null) {
Expand Down Expand Up @@ -133,7 +145,7 @@ private void checkForAspect(ExecutableElement methodElement) {
return;
}
int nameIndex = methodNameIndex(methodElement.getSimpleName().toString());
List<AspectPair> aspectPairs = new AspectAnnotationReader(context, baseType, methodElement).read();
List<AspectPair> aspectPairs = readAspects(methodElement);
aspectPairs.addAll(typeAspects);

if (!aspectPairs.isEmpty()) {
Expand Down