diff --git a/src/core/lombok/core/LombokNode.java b/src/core/lombok/core/LombokNode.java
index d6708956..5a0842bc 100644
--- a/src/core/lombok/core/LombokNode.java
+++ b/src/core/lombok/core/LombokNode.java
@@ -40,7 +40,6 @@ import lombok.core.AST.Kind;
* For example, JCTree for javac, and ASTNode for Eclipse.
*/
public abstract class LombokNode, L extends LombokNode, N> implements DiagnosticsReceiver {
- protected final A ast;
protected final Kind kind;
protected final N node;
protected LombokImmutableList children;
@@ -59,8 +58,7 @@ public abstract class LombokNode, L extends LombokNode children, Kind kind) {
- this.ast = ast;
+ protected LombokNode(N node, List children, Kind kind) {
this.kind = kind;
this.node = node;
this.children = children != null ? LombokImmutableList.copyOf(children) : LombokImmutableList.of();
@@ -72,9 +70,7 @@ public abstract class LombokNode, L extends LombokNode, L extends LombokNode, L extends LombokNode, L extends LombokNode, L extends LombokNode, L extends LombokNode, L extends LombokNode, L extends LombokNode, L extends LombokNode, L extends LombokNode oldNodes = new IdentityHashMap();
gatherAndRemoveChildren(oldNodes);
- L newNode = ast.buildTree(get(), kind);
+ L newNode = getAst().buildTree(get(), kind);
- ast.setChanged();
+ getAst().setChanged();
- ast.replaceNewWithExistingOld(oldNodes, newNode);
+ getAst().replaceNewWithExistingOld(oldNodes, newNode);
}
@SuppressWarnings({"unchecked", "rawtypes"})
private void gatherAndRemoveChildren(Map map) {
for (LombokNode child : children) child.gatherAndRemoveChildren(map);
- ast.identityDetector.remove(get());
+ getAst().identityDetector.remove(get());
map.put(get(), (L) this);
children = LombokImmutableList.of();
- ast.getNodeMap().remove(get());
+ getAst().getNodeMap().remove(get());
}
/**
@@ -264,7 +260,7 @@ public abstract class LombokNode, L extends LombokNode {
+ private EclipseAST ast;
/** {@inheritDoc} */
EclipseNode(EclipseAST ast, ASTNode node, List children, Kind kind) {
- super(ast, node, children, kind);
+ super(node, children, kind);
+ this.ast = ast;
}
+ @Override
+ public EclipseAST getAst() {
+ return ast;
+ }
/**
* Visits this node and all child nodes depth-first, calling the provided visitor's visit methods.
*/
diff --git a/src/core/lombok/javac/JavacNode.java b/src/core/lombok/javac/JavacNode.java
index 2bce6e3a..3963c892 100644
--- a/src/core/lombok/javac/JavacNode.java
+++ b/src/core/lombok/javac/JavacNode.java
@@ -50,11 +50,18 @@ import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
* Javac specific version of the LombokNode class.
*/
public class JavacNode extends lombok.core.LombokNode {
+ private JavacAST ast;
/**
* Passes through to the parent constructor.
*/
public JavacNode(JavacAST ast, JCTree node, List children, Kind kind) {
- super(ast, node, children, kind);
+ super(node, children, kind);
+ this.ast = ast;
+ }
+
+ @Override
+ public JavacAST getAst() {
+ return ast;
}
public Element getElement() {