diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/lombok/core/LombokNode.java | 4 | ||||
-rw-r--r-- | src/core/lombok/javac/HandlerLibrary.java | 8 | ||||
-rw-r--r-- | src/core/lombok/javac/JavacASTAdapter.java | 5 | ||||
-rw-r--r-- | src/core/lombok/javac/JavacASTVisitor.java | 10 |
4 files changed, 26 insertions, 1 deletions
diff --git a/src/core/lombok/core/LombokNode.java b/src/core/lombok/core/LombokNode.java index 6d0f3147..4a57e080 100644 --- a/src/core/lombok/core/LombokNode.java +++ b/src/core/lombok/core/LombokNode.java @@ -78,6 +78,10 @@ public abstract class LombokNode<A extends AST<A, L, N>, L extends LombokNode<A, this.isStructurallySignificant = calculateIsStructurallySignificant(null); } + public A getAst() { + return ast; + } + /** {@inheritDoc} */ @Override public String toString() { return String.format("NODE %s (%s) %s%s", diff --git a/src/core/lombok/javac/HandlerLibrary.java b/src/core/lombok/javac/HandlerLibrary.java index bbbdacd0..5b792874 100644 --- a/src/core/lombok/javac/HandlerLibrary.java +++ b/src/core/lombok/javac/HandlerLibrary.java @@ -183,7 +183,13 @@ public class HandlerLibrary { */ public void callASTVisitors(JavacAST ast) { for (JavacASTVisitor visitor : visitorHandlers) try { - ast.traverse(visitor); + if (!visitor.isResolutionBased()) ast.traverse(visitor); + } catch (Throwable t) { + javacError(String.format("Lombok visitor handler %s failed", visitor.getClass()), t); + } + + for (JavacASTVisitor visitor : visitorHandlers) try { + if (visitor.isResolutionBased()) ast.traverse(visitor); } catch (Throwable t) { javacError(String.format("Lombok visitor handler %s failed", visitor.getClass()), t); } diff --git a/src/core/lombok/javac/JavacASTAdapter.java b/src/core/lombok/javac/JavacASTAdapter.java index 41bc46d3..bbdb6876 100644 --- a/src/core/lombok/javac/JavacASTAdapter.java +++ b/src/core/lombok/javac/JavacASTAdapter.java @@ -35,6 +35,11 @@ import com.sun.tools.javac.tree.JCTree.JCVariableDecl; */ public class JavacASTAdapter implements JavacASTVisitor { /** {@inheritDoc} */ + @Override public boolean isResolutionBased() { + return false; + } + + /** {@inheritDoc} */ @Override public void visitCompilationUnit(JavacNode top, JCCompilationUnit unit) {} /** {@inheritDoc} */ diff --git a/src/core/lombok/javac/JavacASTVisitor.java b/src/core/lombok/javac/JavacASTVisitor.java index 3c5887a7..18376037 100644 --- a/src/core/lombok/javac/JavacASTVisitor.java +++ b/src/core/lombok/javac/JavacASTVisitor.java @@ -38,6 +38,12 @@ import com.sun.tools.javac.tree.JCTree.JCVariableDecl; */ public interface JavacASTVisitor { /** + * If true, you'll be called after all the non-resolution based visitors. + * NB: Temporary solution - will be rewritten to a different style altogether in a future release. + */ + boolean isResolutionBased(); + + /** * Called at the very beginning and end. */ void visitCompilationUnit(JavacNode top, JCCompilationUnit unit); @@ -101,6 +107,10 @@ public interface JavacASTVisitor { private int disablePrinting = 0; private int indent = 0; + @Override public boolean isResolutionBased() { + return false; + } + /** * @param printContent if true, bodies are printed directly, as java code, * instead of a tree listing of every AST node inside it. |