public class TreePathCacher
extends com.sun.source.util.TreeScanner<com.sun.source.util.TreePath,com.sun.source.tree.Tree>
This class replicates some logic from TreePath.getPath but also adds caching to all intermediate TreePaths that are generated. The intermediate TreePaths are reused when other targets have overlapping paths.
| Constructor and Description | 
|---|
TreePathCacher()  | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
clear()  | 
com.sun.source.util.TreePath | 
getPath(com.sun.source.tree.CompilationUnitTree root,
       com.sun.source.tree.Tree target)
Return the TreePath for a Tree. 
 | 
boolean | 
isCached(com.sun.source.tree.Tree target)  | 
com.sun.source.util.TreePath | 
scan(com.sun.source.tree.Tree tree,
    com.sun.source.tree.Tree target)
Scan a single node. 
 | 
reduce, scan, visitAnnotatedType, visitAnnotation, visitArrayAccess, visitArrayType, visitAssert, visitAssignment, visitBinary, visitBlock, visitBreak, visitCase, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitContinue, visitDoWhileLoop, visitEmptyStatement, visitEnhancedForLoop, visitErroneous, visitExpressionStatement, visitForLoop, visitIdentifier, visitIf, visitImport, visitInstanceOf, visitIntersectionType, visitLabeledStatement, visitLambdaExpression, visitLiteral, visitMemberReference, visitMemberSelect, visitMethod, visitMethodInvocation, visitModifiers, visitNewArray, visitNewClass, visitOther, visitParameterizedType, visitParenthesized, visitPrimitiveType, visitReturn, visitSwitch, visitSynchronized, visitThrow, visitTry, visitTypeCast, visitTypeParameter, visitUnary, visitUnionType, visitVariable, visitWhileLoop, visitWildcardpublic boolean isCached(com.sun.source.tree.Tree target)
target - the tree to search forpublic com.sun.source.util.TreePath getPath(com.sun.source.tree.CompilationUnitTree root,
                                            com.sun.source.tree.Tree target)
This method uses try/catch and the Result Error for control flow to stop the superclass from scanning other subtrees when target is found.
root - the compilation unit to search intarget - the target tree to look forpublic void clear()
public com.sun.source.util.TreePath scan(com.sun.source.tree.Tree tree,
                                         com.sun.source.tree.Tree target)
scan in class com.sun.source.util.TreeScanner<com.sun.source.util.TreePath,com.sun.source.tree.Tree>