Skip to content

Commit ebfa952

Browse files
fix issue where second (redundant) run of annotation processor overwrites result of first run
1 parent d93b645 commit ebfa952

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/io/github/bldl/annotationProcessing/VarianceProcessor.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
5353
ClassHierarchyGraph<String> classHierarchy = astManipulator.computeClassHierarchy();
5454
messager.printMessage(Kind.NOTE, classHierarchy.toString());
5555
messager.printMessage(Kind.NOTE, "Processing annotations:\n");
56+
boolean workHasBeenDone = false;
5657
for (Class<? extends Annotation> annotationType : supportedAnnotations) {
5758
for (Element e : roundEnv.getElementsAnnotatedWith(annotationType)) {
59+
workHasBeenDone = true;
5860
MyVariance annotation = e.getAnnotation(MyVariance.class);
5961
try {
6062
if (annotationType.equals(Covariant.class))
@@ -73,7 +75,8 @@ else if (annotationType.equals(Contravariant.class))
7375
messager.printMessage(Kind.WARNING, "Could not parse annotation for element: " + e);
7476
}
7577
}
76-
astManipulator.applyChanges();
78+
if (workHasBeenDone)
79+
astManipulator.applyChanges();
7780
return true;
7881
}
7982

0 commit comments

Comments
 (0)