Class CastScanner
java.lang.Object
com.sun.source.util.TreeScanner<Void,Void>
com.sun.source.util.TreePathScanner<Void,Void>
org.checkerframework.afu.annotator.scanner.CommonScanner
org.checkerframework.afu.annotator.scanner.CastScanner
- All Implemented Interfaces:
TreeVisitor<Void,
Void>
CastScanner stores information about the names and offsets of casts inside a method, and can also
be used to scan the source tree and determine the index of a given cast, where the i^th index
corresponds to the i^th cast, using 0-based indexing.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addCastToMethod
(String methodName, Integer offset) Adds a cast bytecode offset to the current list of offsets for methodName.static Integer
getMethodCastIndex
(String methodName, Integer offset) Returns the index of the given offset within the list of offsets for the given method, using 0-based indexing, or returns a negative number if the offset is not one of the offsets in the method.static int
indexOfCastTree
(TreePath origpath, Tree tree) Computes the index of the given cast tree amongst all cast trees inside its method, using 0-based indexing.visitTypeCast
(TypeCastTree node, Void p) Methods inherited from class org.checkerframework.afu.annotator.scanner.CommonScanner
visitClass
Methods inherited from class com.sun.source.util.TreePathScanner
getCurrentPath, scan, scan
Methods inherited from class com.sun.source.util.TreeScanner
reduce, scan, visitAnnotatedType, visitAnnotation, visitAnyPattern, visitArrayAccess, visitArrayType, visitAssert, visitAssignment, visitBinary, visitBindingPattern, visitBlock, visitBreak, visitCase, visitCatch, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitConstantCaseLabel, visitContinue, visitDeconstructionPattern, visitDefaultCaseLabel, visitDoWhileLoop, visitEmptyStatement, visitEnhancedForLoop, visitErroneous, visitExports, visitExpressionStatement, visitForLoop, visitIdentifier, visitIf, visitImport, visitInstanceOf, visitIntersectionType, visitLabeledStatement, visitLambdaExpression, visitLiteral, visitMemberReference, visitMemberSelect, visitMethod, visitMethodInvocation, visitModifiers, visitModule, visitNewArray, visitNewClass, visitOpens, visitOther, visitPackage, visitParameterizedType, visitParenthesized, visitPatternCaseLabel, visitPrimitiveType, visitProvides, visitRequires, visitReturn, visitStringTemplate, visitSwitch, visitSwitchExpression, visitSynchronized, visitThrow, visitTry, visitTypeParameter, visitUnary, visitUnionType, visitUses, visitVariable, visitWhileLoop, visitWildcard, visitYield
-
Method Details
-
indexOfCastTree
Computes the index of the given cast tree amongst all cast trees inside its method, using 0-based indexing.- Parameters:
origpath
- the path ending in the given cast treetree
- the cast tree to search for- Returns:
- the index of the given cast tree
-
visitTypeCast
- Specified by:
visitTypeCast
in interfaceTreeVisitor<Void,
Void> - Overrides:
visitTypeCast
in classTreeScanner<Void,
Void>
-
addCastToMethod
Adds a cast bytecode offset to the current list of offsets for methodName. This method must be called with monotonically increasing offsets for any one method.- Parameters:
methodName
- the name of the methodoffset
- the offset to add
-
getMethodCastIndex
Returns the index of the given offset within the list of offsets for the given method, using 0-based indexing, or returns a negative number if the offset is not one of the offsets in the method.- Parameters:
methodName
- the name of the methodoffset
- the offset of the instanceof check- Returns:
- the index of the given offset, or a negative number if the given offset does not exists inside the method
-