diff options
author | Reinier Zwitserloot <reinier@tipit.to> | 2009-06-17 21:57:54 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@tipit.to> | 2009-06-17 21:57:54 +0200 |
commit | eca3cd7ccc6e8c5736f5a70c3b1c095bd949689d (patch) | |
tree | 872695cfa92999e0ad1bd8843d08f9760aaebad6 /src/lombok/eclipse/TransformEclipseAST.java | |
parent | 8fa50054449d88380ce45ba91881df6655737f20 (diff) | |
download | lombok-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/TransformEclipseAST.java')
-rw-r--r-- | src/lombok/eclipse/TransformEclipseAST.java | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/lombok/eclipse/TransformEclipseAST.java b/src/lombok/eclipse/TransformEclipseAST.java index f77639e1..b56c594a 100644 --- a/src/lombok/eclipse/TransformEclipseAST.java +++ b/src/lombok/eclipse/TransformEclipseAST.java @@ -115,32 +115,37 @@ public class TransformEclipseAST { private static class AnnotationVisitor extends EclipseASTAdapter { @Override public void visitAnnotationOnField(FieldDeclaration field, Node annotationNode, Annotation annotation) { if ( annotationNode.isHandled() ) return; - handlers.handle((CompilationUnitDeclaration) annotationNode.top().get(), annotationNode, annotation); - annotationNode.setHandled(); + CompilationUnitDeclaration top = (CompilationUnitDeclaration) annotationNode.top().get(); + boolean handled = handlers.handle(top, annotationNode, annotation); + if ( handled ) annotationNode.setHandled(); } @Override public void visitAnnotationOnMethodArgument(Argument arg, AbstractMethodDeclaration method, Node annotationNode, Annotation annotation) { if ( annotationNode.isHandled() ) return; - handlers.handle((CompilationUnitDeclaration) annotationNode.top().get(), annotationNode, annotation); - annotationNode.setHandled(); + CompilationUnitDeclaration top = (CompilationUnitDeclaration) annotationNode.top().get(); + boolean handled = handlers.handle(top, annotationNode, annotation); + if ( handled ) annotationNode.setHandled(); } @Override public void visitAnnotationOnLocal(LocalDeclaration local, Node annotationNode, Annotation annotation) { if ( annotationNode.isHandled() ) return; - handlers.handle((CompilationUnitDeclaration) annotationNode.top().get(), annotationNode, annotation); - annotationNode.setHandled(); + CompilationUnitDeclaration top = (CompilationUnitDeclaration) annotationNode.top().get(); + boolean handled = handlers.handle(top, annotationNode, annotation); + if ( handled ) annotationNode.setHandled(); } @Override public void visitAnnotationOnMethod(AbstractMethodDeclaration method, Node annotationNode, Annotation annotation) { if ( annotationNode.isHandled() ) return; - handlers.handle((CompilationUnitDeclaration) annotationNode.top().get(), annotationNode, annotation); - annotationNode.setHandled(); + CompilationUnitDeclaration top = (CompilationUnitDeclaration) annotationNode.top().get(); + boolean handled = handlers.handle(top, annotationNode, annotation); + if ( handled ) annotationNode.setHandled(); } @Override public void visitAnnotationOnType(TypeDeclaration type, Node annotationNode, Annotation annotation) { if ( annotationNode.isHandled() ) return; - handlers.handle((CompilationUnitDeclaration) annotationNode.top().get(), annotationNode, annotation); - annotationNode.setHandled(); + CompilationUnitDeclaration top = (CompilationUnitDeclaration) annotationNode.top().get(); + boolean handled = handlers.handle(top, annotationNode, annotation); + if ( handled ) annotationNode.setHandled(); } } } |