From e24ac22aaa286cb91a0dcdbff1f95d09fb62f8ef Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 21 Nov 2011 23:53:00 +0100 Subject: Made an API for creating a (oracle javac) JavaCompiler which tracks comments on a per Compilation Unit basis. The old way involved making reflective calls and detecting whether you need the 1.6 or the 1.7 variant to do this. These shenanigans are now hidden behind a nice API (lombok.javac.CommentCatcher). --- src/core/lombok/javac/JavacNode.java | 4 +--- src/core/lombok/javac/JavacTransformer.java | 6 +----- src/core/lombok/javac/LombokOptions.java | 19 ++++++++++++++++--- 3 files changed, 18 insertions(+), 11 deletions(-) (limited to 'src/core/lombok') diff --git a/src/core/lombok/javac/JavacNode.java b/src/core/lombok/javac/JavacNode.java index 5b4782e8..b478781b 100644 --- a/src/core/lombok/javac/JavacNode.java +++ b/src/core/lombok/javac/JavacNode.java @@ -39,7 +39,6 @@ import com.sun.tools.javac.tree.JCTree.JCMethodDecl; import com.sun.tools.javac.tree.JCTree.JCVariableDecl; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.Name; -import com.sun.tools.javac.util.Options; import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; /** @@ -198,8 +197,7 @@ public class JavacNode extends lombok.core.LombokNode changed = new HashSet(); - public boolean deleteLombokAnnotations = true; - public final Set changed = new HashSet(); - public static LombokOptions replaceWithDelombokOptions(Context context) { Options options = Options.instance(context); context.put(optionsKey, (Options)null); @@ -41,6 +40,20 @@ public class LombokOptions extends Options { return result; } + public boolean isChanged(JCCompilationUnit ast) { + return changed.contains(ast); + } + + public static void markChanged(Context context, JCCompilationUnit ast) { + Options options = context.get(Options.optionsKey); + if (options instanceof LombokOptions) ((LombokOptions) options).changed.add(ast); + } + + public static boolean shouldDeleteLombokAnnotations(Context context) { + Options options = context.get(Options.optionsKey); + return (options instanceof LombokOptions) && ((LombokOptions) options).deleteLombokAnnotations; + } + private LombokOptions(Context context) { super(context); } -- cgit