Class DoubleJavacVisitor

java.lang.Object
com.sun.source.util.SimpleTreeVisitor<Void,Tree>
org.checkerframework.framework.ajava.DoubleJavacVisitor
All Implemented Interfaces:
TreeVisitor<Void,Tree>

public abstract class DoubleJavacVisitor extends SimpleTreeVisitor<Void,Tree>
A visitor that traverses two javac ASTs simultaneously. The two trees must be structurally identical (modulo differences, such as annotations and explicit receiver parameters, between a Java file and its corresponding .ajava file).

The entry point is scan(Tree, Tree). Given two corresponding trees, scan performs basic structural checks and then calls Tree.accept(com.sun.source.tree.TreeVisitor<R, D>, D) on the first tree to dispatch to the appropriate visitXyz method. The visitXyz methods in this base class drive paired recursion explicitly by calling scan(Tree, Tree) and scanList(List, List) on corresponding child trees.

To use this class, extend it and override defaultAction(Tree, Tree) to perform work for each matched pair of trees. Subclasses may also override specific visitXyz methods to customize behavior, but do not need to override root methods such as visitCompilationUnit or visitClass unless they want to change traversal.

WARNING: This class intentionally does not behave like TreeScanner. Although it subclasses SimpleTreeVisitor, recursion is not automatic. To recurse, the visitXyz methods in this class and any subclass must explicitly call scan(com.sun.source.tree.Tree, com.sun.source.tree.Tree) or scanList(java.util.List<? extends com.sun.source.tree.Tree>, java.util.List<? extends com.sun.source.tree.Tree>). This makes recursion explicit and keeps all paired-tree structural checks in scan(Tree, Tree) rather than duplicating them in every visitXyz method.

This base visitor does not compare or traverse annotation lists, since annotations may legitimately differ between a Java file and its corresponding .ajava file. Subclasses may change that behavior.