Skip to content

Commit

Permalink
[GR-56344] Make all annotation processors claim their annotations
Browse files Browse the repository at this point in the history
* To avoid extra annotation processing work.
  • Loading branch information
eregon committed Jul 25, 2024
1 parent d81eb53 commit 3f2f41a
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ protected boolean doProcess(Set<? extends TypeElement> annotations, RoundEnviron
createStubs(this, targetVM, (TypeElement) holder, classes);
}
}
return false;
return true;
}

private void extractStubs(TargetVM targetVM,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,6 @@ protected boolean doProcess(Set<? extends TypeElement> annotations, RoundEnviron
}
}
}
return false;
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ boolean isNodeType(Element element) {
@Override
public boolean doProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if (roundEnv.processingOver()) {
return false;
return true;
}

GraphNodeVerifier verifier = new GraphNodeVerifier(this);
Expand Down Expand Up @@ -172,7 +172,7 @@ public boolean doProcess(Set<? extends TypeElement> annotations, RoundEnvironmen
scope = null;
}
}
return false;
return true;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
return doProcess(annotations, roundEnv);
}

/**
* Implementations should claim their annotations by returning {@code true} to avoid extra
* annotation processing work.
*/
protected abstract boolean doProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv);

private final Map<String, TypeElement> types = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public boolean doProcess(Set<? extends TypeElement> annotations, RoundEnvironmen
}
generator.generateAll(this);
}
return false;
return true;
}

public List<AnnotationHandler> getHandlers() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@
import com.oracle.truffle.dsl.processor.java.transform.FixWarningsVisitor;
import com.oracle.truffle.dsl.processor.java.transform.GenerateOverrideVisitor;

@SupportedAnnotationTypes({
TruffleTypes.GenerateWrapper_Name})
@SupportedAnnotationTypes({TruffleTypes.GenerateWrapper_Name})
public final class InstrumentableProcessor extends AbstractProcessor {

// configuration
Expand Down Expand Up @@ -112,7 +111,7 @@ public SourceVersion getSupportedSourceVersion() {
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if (roundEnv.processingOver()) {
return false;
return true;
}
try (ProcessorContext context = ProcessorContext.enter(processingEnv)) {
TruffleTypes types = context.getTypes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
}
}
}
return false;
return true;
}

private static void processElement(AnnotationProcessor<?> generator, Element e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public SourceVersion getSupportedSourceVersion() {
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if (roundEnv.processingOver()) {
return false;
return true;
}
try (ProcessorContext context = ProcessorContext.enter(processingEnv)) {
TruffleTypes types = context.getTypes();
Expand All @@ -85,7 +85,7 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
}
assertNoErrorExpected(element);
}
return false;
return true;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private void reportException(Kind kind, Element element, Throwable t) {
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if (roundEnv.processingOver()) {
return false;
return true;
}

try (ProcessorContext context = ProcessorContext.enter(processingEnv)) {
Expand Down Expand Up @@ -220,7 +220,7 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
}
}

return false;
return true;
}
}

Expand Down

0 comments on commit 3f2f41a

Please sign in to comment.