From dfa401018d0eff370b34f1e9d7bb1d5fd498a631 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 30 Nov 2009 00:49:42 +0100 Subject: All basic elements of netbeans support are here except the actual agent part. --- src/core/lombok/javac/JavacAST.java | 1 + 1 file changed, 1 insertion(+) (limited to 'src/core/lombok/javac') diff --git a/src/core/lombok/javac/JavacAST.java b/src/core/lombok/javac/JavacAST.java index 33c167f9..9cfe7f34 100644 --- a/src/core/lombok/javac/JavacAST.java +++ b/src/core/lombok/javac/JavacAST.java @@ -125,6 +125,7 @@ public class JavacAST extends AST { /** @return A TreeMaker instance that you can use to create new AST nodes. */ public TreeMaker getTreeMaker() { + treeMaker.at(-1); return treeMaker; } -- cgit From 5bd3abdfe528344f0ae965b99332e20d7581680c Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Wed, 2 Dec 2009 00:05:28 +0100 Subject: [TRIVIAL] --- src/core/lombok/javac/HandlerLibrary.java | 49 ++++++++++++------------------- 1 file changed, 19 insertions(+), 30 deletions(-) (limited to 'src/core/lombok/javac') diff --git a/src/core/lombok/javac/HandlerLibrary.java b/src/core/lombok/javac/HandlerLibrary.java index bbe9dec0..48218513 100644 --- a/src/core/lombok/javac/HandlerLibrary.java +++ b/src/core/lombok/javac/HandlerLibrary.java @@ -21,14 +21,12 @@ */ package lombok.javac; +import java.io.IOException; import java.lang.annotation.Annotation; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; -import java.util.ServiceConfigurationError; -import java.util.ServiceLoader; import javax.annotation.processing.Messager; import javax.tools.Diagnostic; @@ -85,46 +83,36 @@ public class HandlerLibrary { public static HandlerLibrary load(Messager messager) { HandlerLibrary library = new HandlerLibrary(messager); - loadAnnotationHandlers(library); - loadVisitorHandlers(library); + try { + loadAnnotationHandlers(library); + loadVisitorHandlers(library); + } catch (IOException e) { + System.err.println("Lombok isn't running due to misconfigured SPI files: " + e); + } return library; } /** Uses SPI Discovery to find implementations of {@link JavacAnnotationHandler}. */ @SuppressWarnings("unchecked") - private static void loadAnnotationHandlers(HandlerLibrary lib) { + private static void loadAnnotationHandlers(HandlerLibrary lib) throws IOException { //No, that seemingly superfluous reference to JavacAnnotationHandler's classloader is not in fact superfluous! - Iterator it = ServiceLoader.load(JavacAnnotationHandler.class, - JavacAnnotationHandler.class.getClassLoader()).iterator(); - while (it.hasNext()) { - try { - JavacAnnotationHandler handler = it.next(); - Class annotationClass = - SpiLoadUtil.findAnnotationClass(handler.getClass(), JavacAnnotationHandler.class); - AnnotationHandlerContainer container = new AnnotationHandlerContainer(handler, annotationClass); - if (lib.annotationHandlers.put(container.annotationClass.getName(), container) != null) { - lib.javacWarning("Duplicate handlers for annotation type: " + container.annotationClass.getName()); - } - lib.typeLibrary.addType(container.annotationClass.getName()); - } catch (ServiceConfigurationError e) { - lib.javacWarning("Can't load Lombok annotation handler for javac", e); + for (JavacAnnotationHandler handler : SpiLoadUtil.findServices(JavacAnnotationHandler.class, JavacAnnotationHandler.class.getClassLoader())) { + Class annotationClass = + SpiLoadUtil.findAnnotationClass(handler.getClass(), JavacAnnotationHandler.class); + AnnotationHandlerContainer container = new AnnotationHandlerContainer(handler, annotationClass); + if (lib.annotationHandlers.put(container.annotationClass.getName(), container) != null) { + lib.javacWarning("Duplicate handlers for annotation type: " + container.annotationClass.getName()); } + lib.typeLibrary.addType(container.annotationClass.getName()); } } /** Uses SPI Discovery to find implementations of {@link JavacASTVisitor}. */ - private static void loadVisitorHandlers(HandlerLibrary lib) { + private static void loadVisitorHandlers(HandlerLibrary lib) throws IOException { //No, that seemingly superfluous reference to JavacASTVisitor's classloader is not in fact superfluous! - Iterator it = ServiceLoader.load(JavacASTVisitor.class, - JavacASTVisitor.class.getClassLoader()).iterator(); - while (it.hasNext()) { - try { - JavacASTVisitor handler = it.next(); - lib.visitorHandlers.add(handler); - } catch (ServiceConfigurationError e) { - lib.javacWarning("Can't load Lombok visitor handler for javac", e); - } + for (JavacASTVisitor visitor : SpiLoadUtil.findServices(JavacASTVisitor.class, JavacASTVisitor.class.getClassLoader())) { + lib.visitorHandlers.add(visitor); } } @@ -177,6 +165,7 @@ public class HandlerLibrary { if (container == null) continue; try { + System.out.println("Calling handle on: "+ container.handler.getClass().getName()); handled |= container.handle(node); } catch (AnnotationValueDecodeFail fail) { fail.owner.setError(fail.getMessage(), fail.idx); -- cgit