aboutsummaryrefslogtreecommitdiff
path: root/src/lombok/eclipse/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/eclipse/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/eclipse/HandlerLibrary.java')
-rw-r--r--src/lombok/eclipse/HandlerLibrary.java13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/lombok/eclipse/HandlerLibrary.java b/src/lombok/eclipse/HandlerLibrary.java
index 2e3e4541..86efd53e 100644
--- a/src/lombok/eclipse/HandlerLibrary.java
+++ b/src/lombok/eclipse/HandlerLibrary.java
@@ -45,7 +45,7 @@ public class HandlerLibrary {
this.annotationClass = annotationClass;
}
- public void handle(org.eclipse.jdt.internal.compiler.ast.Annotation annotation,
+ public boolean handle(org.eclipse.jdt.internal.compiler.ast.Annotation annotation,
final Node annotationNode) {
Map<String, AnnotationValue> values = new HashMap<String, AnnotationValue>();
@@ -94,7 +94,7 @@ public class HandlerLibrary {
});
}
- handler.handle(new AnnotationValues<T>(annotationClass, values, annotationNode), annotation, annotationNode);
+ return handler.handle(new AnnotationValues<T>(annotationClass, values, annotationNode), annotation, annotationNode);
}
}
@@ -169,26 +169,29 @@ public class HandlerLibrary {
}
}
- public void handle(CompilationUnitDeclaration ast, EclipseAST.Node annotationNode,
+ public boolean handle(CompilationUnitDeclaration ast, EclipseAST.Node annotationNode,
org.eclipse.jdt.internal.compiler.ast.Annotation annotation) {
String pkgName = annotationNode.getPackageDeclaration();
Collection<String> imports = annotationNode.getImportStatements();
TypeResolver resolver = new TypeResolver(typeLibrary, pkgName, imports);
TypeReference rawType = annotation.type;
- if ( rawType == null ) return;
+ if ( rawType == null ) return false;
+ boolean handled = false;
for ( String fqn : resolver.findTypeMatches(annotationNode, toQualifiedName(annotation.type.getTypeName())) ) {
AnnotationHandlerContainer<?> container = annotationHandlers.get(fqn);
if ( container == null ) continue;
try {
- container.handle(annotation, annotationNode);
+ handled |= container.handle(annotation, annotationNode);
} catch ( AnnotationValueDecodeFail fail ) {
fail.owner.setError(fail.getMessage(), fail.idx);
} catch ( Throwable t ) {
Eclipse.error(String.format("Lombok annotation handler %s failed", container.handler.getClass()), t);
}
}
+
+ return handled;
}
public void callASTVisitors(EclipseAST ast) {