checkers.nullness
Class NullnessVisitor
java.lang.Object
com.sun.source.util.TreeScanner<R,P>
com.sun.source.util.TreePathScanner<R,P>
checkers.source.SourceVisitor<R,P>
checkers.basetype.BaseTypeVisitor<Void,Void>
checkers.nullness.NullnessVisitor
- All Implemented Interfaces:
- TreeVisitor<Void,Void>
public class NullnessVisitor
- extends BaseTypeVisitor<Void,Void>
A type-checking visitor for the Nullness type system.
This visitor reports errors ("dereference.of.nullable") or
warnings for violations for the following cases:
1. if the receiver of a member dereference is not NonNull
2. if the receiver of an implicit ".iterator()" dereference in an enhanced
for loop is not NonNull
3. if an accessed array is not NonNull
Self-accesses (via this
or super
) can always be dereferenced.
- See Also:
NullnessChecker
Methods inherited from class checkers.basetype.BaseTypeVisitor |
checkArguments, checkAssignability, checkOverride, checkTypeArguments, commonAssignmentCheck, commonAssignmentCheck, commonAssignmentCheck, scan, shouldSkip, shouldSkip, validateTypeOf, visitAnnotation, visitAssignment, visitClass, visitCompilationUnit, visitCompoundAssignment, visitInstanceOf, visitMethod, visitMethodInvocation, visitNewArray, visitNewClass, visitParameterizedType, visitReturn, visitTypeCast, visitUnary, visitVariable |
Methods inherited from class com.sun.source.util.TreeScanner |
reduce, scan, visitAnnotatedType, visitArrayType, visitAssert, visitBinary, visitBlock, visitBreak, visitCase, visitCatch, visitConditionalExpression, visitContinue, visitDoWhileLoop, visitEmptyStatement, visitErroneous, visitExpressionStatement, visitForLoop, visitIdentifier, visitIf, visitImport, visitLabeledStatement, visitLiteral, visitModifiers, visitOther, visitParenthesized, visitPrimitiveType, visitSwitch, visitSynchronized, visitThrow, visitTry, visitTypeParameter, visitWhileLoop, visitWildcard |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NullnessVisitor
public NullnessVisitor(NullnessChecker checker,
CompilationUnitTree root)
- Creates a new visitor for type-checking
NonNull
.
- Parameters:
checker
- the checker to useroot
- the root of the input program's AST to check
visitMemberSelect
public Void visitMemberSelect(MemberSelectTree node,
Void p)
- Specified by:
visitMemberSelect
in interface TreeVisitor<Void,Void>
- Overrides:
visitMemberSelect
in class TreeScanner<Void,Void>
visitEnhancedForLoop
public Void visitEnhancedForLoop(EnhancedForLoopTree node,
Void p)
- Description copied from class:
BaseTypeVisitor
- Performs a subtype check, to test whether the node expression
iterable type is a subtype of the variable type in the enhanced for
loop.
If the subtype check fails, it issues a "type.incompatible" error.
- Specified by:
visitEnhancedForLoop
in interface TreeVisitor<Void,Void>
- Overrides:
visitEnhancedForLoop
in class BaseTypeVisitor<Void,Void>
visitArrayAccess
public Void visitArrayAccess(ArrayAccessTree node,
Void p)
- Specified by:
visitArrayAccess
in interface TreeVisitor<Void,Void>
- Overrides:
visitArrayAccess
in class TreeScanner<Void,Void>
checkMethodInvocability
protected boolean checkMethodInvocability(AnnotatedTypeMirror.AnnotatedExecutableType method,
MethodInvocationTree node)
- Description copied from class:
BaseTypeVisitor
- Tests whether the method can be invoked using the receiver of the 'node'
method invocation, and issues a "method.invocation.invalid" if the
invocation is invalid.
This implementation tests whether the receiver in the method invocation
is a subtype of the method receiver type.
- Overrides:
checkMethodInvocability
in class BaseTypeVisitor<Void,Void>
- Parameters:
method
- the type of the invoked methodnode
- the method invocation node
- Returns:
- true iff the call of 'node' is a valid call