From eca3cd7ccc6e8c5736f5a70c3b1c095bd949689d Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Wed, 17 Jun 2009 21:57:54 +0200 Subject: 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. --- src/lombok/eclipse/handlers/HandleGetter.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/lombok/eclipse/handlers/HandleGetter.java') diff --git a/src/lombok/eclipse/handlers/HandleGetter.java b/src/lombok/eclipse/handlers/HandleGetter.java index bf1aa9b0..6be978c6 100644 --- a/src/lombok/eclipse/handlers/HandleGetter.java +++ b/src/lombok/eclipse/handlers/HandleGetter.java @@ -29,8 +29,8 @@ public class HandleGetter implements EclipseAnnotationHandler { annotationNode.addWarning(String.format("Not generating %s(): A method with that name already exists", methodName)); } - @Override public void handle(AnnotationValues annotation, Annotation ast, Node annotationNode) { - if ( !(annotationNode.up().get() instanceof FieldDeclaration) ) return; + @Override public boolean handle(AnnotationValues annotation, Annotation ast, Node annotationNode) { + if ( !(annotationNode.up().get() instanceof FieldDeclaration) ) return false; FieldDeclaration field = (FieldDeclaration) annotationNode.up().get(); TypeReference fieldType = field.type; String getterName = TransformationsUtil.toGetterName( @@ -40,7 +40,7 @@ public class HandleGetter implements EclipseAnnotationHandler { if ( parent.methods != null ) for ( AbstractMethodDeclaration method : parent.methods ) { if ( method.selector != null && new String(method.selector).equals(getterName) ) { generateDuplicateGetterWarning(annotationNode, getterName); - return; + return false; } } @@ -69,6 +69,8 @@ public class HandleGetter implements EclipseAnnotationHandler { newArray[parent.methods.length] = method; parent.methods = newArray; } + + return true; } private int toModifier(AccessLevel value) { -- cgit