From 255bd5907176cb5d2c4fb1cf6a9b48b14af0b4ba Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Sat, 20 Jun 2009 23:46:17 +0200 Subject: Due to a java bug, constants in enums don't work, so instead the default access level for @Getter and @Setter have now just been hardcoded in GetterHandler and SetterHandler. Added ability to look up the Node object for any given AST object on Node itself, as you don't usually have the AST object. Added toString() method generating to @Data, and this required some fancy footwork in finding if we've already generated methods, and editing a generated method to fill in binding and type resolutions. HandleGetter and HandleSetter have been updated to use these features. Exceptions caused by lombok handlers show up in the eclipse error log, but now, if they are related to a CompilationUnit, also as a problem (error) on the CUD - those error log entries are easy to miss! Our ASTs can now be appended to. When you generate a new AST node, you should add it to the AST, obviously. Getter/Setter have been updated to use this. --- src/lombok/eclipse/HandlerLibrary.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/lombok/eclipse/HandlerLibrary.java') diff --git a/src/lombok/eclipse/HandlerLibrary.java b/src/lombok/eclipse/HandlerLibrary.java index 39864e8e..10180963 100644 --- a/src/lombok/eclipse/HandlerLibrary.java +++ b/src/lombok/eclipse/HandlerLibrary.java @@ -63,11 +63,11 @@ public class HandlerLibrary { SpiLoadUtil.findAnnotationClass(handler.getClass(), EclipseAnnotationHandler.class); AnnotationHandlerContainer container = new AnnotationHandlerContainer(handler, annotationClass); if ( lib.annotationHandlers.put(container.annotationClass.getName(), container) != null ) { - Eclipse.error("Duplicate handlers for annotation type: " + container.annotationClass.getName()); + Eclipse.error(null, "Duplicate handlers for annotation type: " + container.annotationClass.getName()); } lib.typeLibrary.addType(container.annotationClass.getName()); } catch ( ServiceConfigurationError e ) { - Eclipse.error("Can't load Lombok annotation handler for eclipse: ", e); + Eclipse.error(null, "Can't load Lombok annotation handler for eclipse: ", e); } } } @@ -78,7 +78,7 @@ public class HandlerLibrary { try { lib.visitorHandlers.add(it.next()); } catch ( ServiceConfigurationError e ) { - Eclipse.error("Can't load Lombok visitor handler for eclipse: ", e); + Eclipse.error(null, "Can't load Lombok visitor handler for eclipse: ", e); } } } @@ -94,6 +94,7 @@ public class HandlerLibrary { boolean handled = false; for ( String fqn : resolver.findTypeMatches(annotationNode, toQualifiedName(annotation.type.getTypeName())) ) { AnnotationHandlerContainer container = annotationHandlers.get(fqn); + if ( container == null ) continue; try { @@ -101,7 +102,7 @@ public class HandlerLibrary { } 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); + Eclipse.error(ast, String.format("Lombok annotation handler %s failed", container.handler.getClass()), t); } } @@ -112,7 +113,8 @@ public class HandlerLibrary { for ( EclipseASTVisitor visitor : visitorHandlers ) try { ast.traverse(visitor); } catch ( Throwable t ) { - Eclipse.error(String.format("Lombok visitor handler %s failed", visitor.getClass()), t); + Eclipse.error((CompilationUnitDeclaration) ast.top().get(), + String.format("Lombok visitor handler %s failed", visitor.getClass()), t); } } } -- cgit