mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-14 12:16:49 +00:00
Some small framework updates to accomodate resolution.
This commit is contained in:
1 parent
fc6670e1c4
commit
6e2924bcf2
4 files changed
+26
-1
No files matched your search
@@ -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",
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,11 @@ import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
|
||||
* has been implemented with an empty body. Override whichever methods you need.
|
||||
*/
|
||||
public class JavacASTAdapter implements JavacASTVisitor {
|
||||
/** {@inheritDoc} */
|
||||
@Override public boolean isResolutionBased() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override public void visitCompilationUnit(JavacNode top, JCCompilationUnit unit) {}
|
||||
|
||||
|
||||
@@ -37,6 +37,12 @@ import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
|
||||
* calling the appropriate visit and endVisit methods.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user