aboutsummaryrefslogtreecommitdiff
path: root/src/lombok/javac
diff options
context:
space:
mode:
Diffstat (limited to 'src/lombok/javac')
-rw-r--r--src/lombok/javac/JavacAST.java23
-rw-r--r--src/lombok/javac/JavacNode.java10
-rw-r--r--src/lombok/javac/apt/Processor.java3
3 files changed, 27 insertions, 9 deletions
diff --git a/src/lombok/javac/JavacAST.java b/src/lombok/javac/JavacAST.java
index 77e365ee..f2c83fb8 100644
--- a/src/lombok/javac/JavacAST.java
+++ b/src/lombok/javac/JavacAST.java
@@ -34,7 +34,6 @@ import lombok.core.AST;
import com.sun.source.util.Trees;
import com.sun.tools.javac.code.Symtab;
-import com.sun.tools.javac.processing.JavacProcessingEnvironment;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.TreeMaker;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
@@ -47,6 +46,7 @@ import com.sun.tools.javac.tree.JCTree.JCImport;
import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
import com.sun.tools.javac.tree.JCTree.JCStatement;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
+import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.Log;
import com.sun.tools.javac.util.Name;
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
@@ -61,23 +61,30 @@ public class JavacAST extends AST<JavacAST, JavacNode, JCTree> {
private final TreeMaker treeMaker;
private final Symtab symtab;
private final Log log;
+ private final Context context;
/**
* Creates a new JavacAST of the provided Compilation Unit.
*
* @param trees The trees instance to use to inspect the compilation unit. Generate via:
* {@code Trees.getInstance(env)}
- * @param env The ProcessingEnvironment object passed e.g. to an annotation processor.
+ * @param messager A Messager for warning and error reporting.
+ * @param context A Context object for interfacing with the compiler.
* @param top The compilation unit, which serves as the top level node in the tree to be built.
*/
- public JavacAST(Trees trees, JavacProcessingEnvironment env, JCCompilationUnit top) {
+ public JavacAST(Trees trees, Messager messager, Context context, JCCompilationUnit top) {
super(top.sourcefile == null ? null : top.sourcefile.toString());
setTop(buildCompilationUnit(top));
- this.messager = env.getMessager();
- this.log = Log.instance(env.getContext());
- this.nameTable = Name.Table.instance(env.getContext());
- this.treeMaker = TreeMaker.instance(env.getContext());
- this.symtab = Symtab.instance(env.getContext());
+ this.context = context;
+ this.messager = messager;
+ this.log = Log.instance(context);
+ this.nameTable = Name.Table.instance(context);
+ this.treeMaker = TreeMaker.instance(context);
+ this.symtab = Symtab.instance(context);
+ }
+
+ public Context getContext() {
+ return context;
}
/** {@inheritDoc} */
diff --git a/src/lombok/javac/JavacNode.java b/src/lombok/javac/JavacNode.java
index 46e06579..a0ee2789 100644
--- a/src/lombok/javac/JavacNode.java
+++ b/src/lombok/javac/JavacNode.java
@@ -36,6 +36,7 @@ import com.sun.tools.javac.tree.JCTree.JCClassDecl;
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
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.JCDiagnostic.DiagnosticPosition;
@@ -164,6 +165,15 @@ public class JavacNode extends lombok.core.LombokNode<JavacAST, JavacNode, JCTre
}
/**
+ * Convenient shortcut to the owning JavacAST object's getContext method.
+ *
+ * @see JavacAST#getContext()
+ */
+ public Context getContext() {
+ return ast.getContext();
+ }
+
+ /**
* Convenient shortcut to the owning JavacAST object's toName method.
*
* @see JavacAST#toName(String)
diff --git a/src/lombok/javac/apt/Processor.java b/src/lombok/javac/apt/Processor.java
index 9f3951bb..1ff1ee88 100644
--- a/src/lombok/javac/apt/Processor.java
+++ b/src/lombok/javac/apt/Processor.java
@@ -93,7 +93,8 @@ public class Processor extends AbstractProcessor {
List<JavacAST> asts = new ArrayList<JavacAST>();
- for (JCCompilationUnit unit : units.keySet()) asts.add(new JavacAST(trees, processingEnv, unit));
+ for (JCCompilationUnit unit : units.keySet()) asts.add(
+ new JavacAST(trees, processingEnv.getMessager(), processingEnv.getContext(), unit));
handlers.skipPrintAST();
for (JavacAST ast : asts) {