Class TreePathCacher
- All Implemented Interfaces:
- TreeVisitor<TreePath,- Tree> 
TreePathCacher is a TreeScanner that creates and caches a TreePath for a target 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 SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidAdds the given key and value to the cache.voidclear()getPath(CompilationUnitTree root, Tree target) Return the TreePath for a Tree.booleanReturns true if the tree is cached.Scan a single node.Methods inherited from class com.sun.source.util.TreeScannerreduce, scan, visitAnnotatedType, visitAnnotation, visitArrayAccess, visitArrayType, visitAssert, visitAssignment, visitBinary, visitBindingPattern, visitBlock, visitBreak, visitCase, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitContinue, visitDefaultCaseLabel, visitDoWhileLoop, visitEmptyStatement, visitEnhancedForLoop, visitErroneous, visitExports, visitExpressionStatement, visitForLoop, visitGuardedPattern, visitIdentifier, visitIf, visitImport, visitInstanceOf, visitIntersectionType, visitLabeledStatement, visitLambdaExpression, visitLiteral, visitMemberReference, visitMemberSelect, visitMethod, visitMethodInvocation, visitModifiers, visitModule, visitNewArray, visitNewClass, visitOpens, visitOther, visitPackage, visitParameterizedType, visitParenthesized, visitParenthesizedPattern, visitPrimitiveType, visitProvides, visitRequires, visitReturn, visitSwitch, visitSwitchExpression, visitSynchronized, visitThrow, visitTry, visitTypeCast, visitTypeParameter, visitUnary, visitUnionType, visitUses, visitVariable, visitWhileLoop, visitWildcard, visitYield
- 
Constructor Details- 
TreePathCacherpublic TreePathCacher()
 
- 
- 
Method Details- 
isCachedReturns true if the tree is cached.- Parameters:
- target- the tree to search for
- Returns:
- true if the tree is cached
 
- 
addPathAdds the given key and value to the cache.- Parameters:
- target- the tree to add
- path- the path to cache
 
- 
getPathReturn the TreePath for a Tree.- Parameters:
- root- the compilation unit to search in
- target- the target tree to look for
- Returns:
- the TreePath corresponding to target, or null if target is not found in the compilation root
 
- 
clearpublic void clear()
- 
scanScan a single node. The current path is updated for the duration of the scan.- Overrides:
- scanin class- TreeScanner<TreePath,- Tree> 
 
 
-