aboutsummaryrefslogtreecommitdiff
path: root/src/lombok/javac/HandlerLibrary.java
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@tipit.to>2009-06-17 21:57:54 +0200
committerReinier Zwitserloot <reinier@tipit.to>2009-06-17 21:57:54 +0200
commiteca3cd7ccc6e8c5736f5a70c3b1c095bd949689d (patch)
tree872695cfa92999e0ad1bd8843d08f9760aaebad6 /src/lombok/javac/HandlerLibrary.java
parent8fa50054449d88380ce45ba91881df6655737f20 (diff)
downloadlombok-eca3cd7ccc6e8c5736f5a70c3b1c095bd949689d.tar.gz
lombok-eca3cd7ccc6e8c5736f5a70c3b1c095bd949689d.tar.bz2
lombok-eca3cd7ccc6e8c5736f5a70c3b1c095bd949689d.zip
AnnotationHandlers can now return a boolean to set if they actually handled the annotation or not (previously, the presumption was they always handled the annotation).
This is very useful for PrintAST on eclipse, because before this change, you'd never see method contents (as the initial dietParse would come first). Now Eclipse PrintASTHandler will skip any non-full runs, and only print non-diet. It then returns true only if it printed.
Diffstat (limited to 'src/lombok/javac/HandlerLibrary.java')
-rw-r--r--src/lombok/javac/HandlerLibrary.java11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/lombok/javac/HandlerLibrary.java b/src/lombok/javac/HandlerLibrary.java
index d816438e..05aebf20 100644
--- a/src/lombok/javac/HandlerLibrary.java
+++ b/src/lombok/javac/HandlerLibrary.java
@@ -67,7 +67,7 @@ public class HandlerLibrary {
} else return null;
}
- public void handle(final JavacAST.Node node) {
+ public boolean handle(final JavacAST.Node node) {
Map<String, AnnotationValue> values = new HashMap<String, AnnotationValue>();
JCAnnotation anno = (JCAnnotation) node.get();
List<JCExpression> arguments = anno.getArguments();
@@ -104,7 +104,7 @@ public class HandlerLibrary {
});
}
- handler.handle(new AnnotationValues<T>(annotationClass, values, node), (JCAnnotation)node.get(), node);
+ return handler.handle(new AnnotationValues<T>(annotationClass, values, node), (JCAnnotation)node.get(), node);
}
}
@@ -168,21 +168,24 @@ public class HandlerLibrary {
}
}
- public void handleAnnotation(JCCompilationUnit unit, JavacAST.Node node, JCAnnotation annotation) {
+ public boolean handleAnnotation(JCCompilationUnit unit, JavacAST.Node node, JCAnnotation annotation) {
TypeResolver resolver = new TypeResolver(typeLibrary, node.getPackageDeclaration(), node.getImportStatements());
String rawType = annotation.annotationType.toString();
+ boolean handled = false;
for ( String fqn : resolver.findTypeMatches(node, rawType) ) {
AnnotationHandlerContainer<?> container = annotationHandlers.get(fqn);
if ( container == null ) continue;
try {
- container.handle(node);
+ handled |= container.handle(node);
} catch ( AnnotationValueDecodeFail fail ) {
fail.owner.setError(fail.getMessage(), fail.idx);
} catch ( Throwable t ) {
javacError(String.format("Lombok annotation handler %s failed", container.handler.getClass()), t);
}
}
+
+ return handled;
}
public void callASTVisitors(JavacAST ast) {