Class NullnessNoInitVisitor
- java.lang.Object
-
- com.sun.source.util.TreeScanner<R,P>
-
- com.sun.source.util.TreePathScanner<R,P>
-
- org.checkerframework.framework.source.SourceVisitor<java.lang.Void,java.lang.Void>
-
- org.checkerframework.common.basetype.BaseTypeVisitor<NullnessNoInitAnnotatedTypeFactory>
-
- org.checkerframework.checker.nullness.NullnessNoInitVisitor
-
- All Implemented Interfaces:
com.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
public class NullnessNoInitVisitor extends BaseTypeVisitor<NullnessNoInitAnnotatedTypeFactory>
The visitor for the nullness type-system.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.checkerframework.common.basetype.BaseTypeVisitor
BaseTypeVisitor.FoundRequired, BaseTypeVisitor.OverrideChecker
-
-
Field Summary
-
Fields inherited from class org.checkerframework.common.basetype.BaseTypeVisitor
atypeFactory, checker, DETERMINISTIC, ignoreTargetLocations, IMPURE, methodTree, positions, PURE, qualAllowedLocations, qualHierarchy, showchecks, SIDE_EFFECT_FREE, TARGET, targetValueElement, typeHierarchy, typeValidator, unusedWhenElement
-
Fields inherited from class org.checkerframework.framework.source.SourceVisitor
elements, root, trees, treesWithSuppressWarnings, types
-
-
Constructor Summary
Constructors Constructor Description NullnessNoInitVisitor(BaseTypeChecker checker)
Create a new NullnessVisitor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkConstructorResult(AnnotatedTypeMirror.AnnotatedExecutableType constructorType, javax.lang.model.element.ExecutableElement constructorElement)
Issue a warning if the result type of the constructor declaration is not top.protected void
checkExceptionParameter(com.sun.source.tree.CatchTree tree)
Issue error if the exception parameter is not a supertype of the annotation specified byBaseTypeVisitor.getExceptionParameterLowerBoundAnnotations()
, which is top by default.protected void
checkForRedundantTests(com.sun.source.tree.BinaryTree tree)
Reports an error if a comparison of a @NonNull expression with the null literal is performed.protected void
checkMethodInvocability(AnnotatedTypeMirror.AnnotatedExecutableType method, com.sun.source.tree.MethodInvocationTree tree)
Tests whether the method can be invoked using the receiver of the 'tree' method invocation, and issues a "method.invocation.invalid" if the invocation is invalid.protected void
checkThisOrSuperConstructorCall(com.sun.source.tree.MethodInvocationTree superCall, @CompilerMessageKey java.lang.String errorKey)
Checks that the following rule is satisfied: The type on a constructor declaration must be a supertype of the return type of "this()" or "super()" invocation within that constructor.protected void
checkThrownExpression(com.sun.source.tree.ThrowTree tree)
Case 4: Check for thrown exception nullness.protected boolean
commonAssignmentCheck(com.sun.source.tree.Tree varTree, com.sun.source.tree.ExpressionTree valueExp, @CompilerMessageKey java.lang.String errorKey, java.lang.Object... extraArgs)
Checks the validity of an assignment (or pseudo-assignment) from a value to a variable and emits an error message (through the compiler's messaging interface) if it is not valid.protected boolean
commonAssignmentCheck(AnnotatedTypeMirror varType, com.sun.source.tree.ExpressionTree valueExp, @CompilerMessageKey java.lang.String errorKey, java.lang.Object... extraArgs)
Checks the validity of an assignment (or pseudo-assignment) from a value to a variable and emits an error message (through the compiler's messaging interface) if it is not valid.protected boolean
commonAssignmentCheck(AnnotatedTypeMirror varType, AnnotatedTypeMirror valueType, com.sun.source.tree.Tree valueTree, @CompilerMessageKey java.lang.String errorKey, java.lang.Object... extraArgs)
Checks the validity of an assignment (or pseudo-assignment) from a value to a variable and emits an error message (through the compiler's messaging interface) if it is not valid.NullnessNoInitAnnotatedTypeFactory
createTypeFactory()
Constructs an instance of the appropriate type factory for the implemented type system.protected TypeValidator
createTypeValidator()
boolean
isValidUse(AnnotatedTypeMirror.AnnotatedPrimitiveType type, com.sun.source.tree.Tree tree)
Tests that the qualifiers present on the primitive type are valid.void
processClassTree(com.sun.source.tree.ClassTree classTree)
Type-check classTree.void
visitAnnotatedType(@Nullable java.util.List<? extends com.sun.source.tree.AnnotationTree> annoTrees, com.sun.source.tree.Tree typeTree)
Checks an annotated type.java.lang.Void
visitAnnotation(com.sun.source.tree.AnnotationTree tree, java.lang.Void p)
Ensure that the annotation arguments comply to their declarations.java.lang.Void
visitArrayAccess(com.sun.source.tree.ArrayAccessTree tree, java.lang.Void p)
Case 3: Check for array dereferencing.java.lang.Void
visitAssert(com.sun.source.tree.AssertTree tree, java.lang.Void p)
java.lang.Void
visitBinary(com.sun.source.tree.BinaryTree tree, java.lang.Void p)
Case 6: Check for redundant nullness tests Case 7: unboxing case: primitive operations.java.lang.Void
visitCompoundAssignment(com.sun.source.tree.CompoundAssignmentTree tree, java.lang.Void p)
Case 7: unboxing case: primitive operation.java.lang.Void
visitConditionalExpression(com.sun.source.tree.ConditionalExpressionTree tree, java.lang.Void p)
If the computation of the type of the ConditionalExpressionTree in org.checkerframework.framework.type.TypeFromTree.TypeFromExpression.visitConditionalExpression(ConditionalExpressionTree, AnnotatedTypeFactory) is correct, the following checks are redundant.java.lang.Void
visitDoWhileLoop(com.sun.source.tree.DoWhileLoopTree tree, java.lang.Void p)
java.lang.Void
visitEnhancedForLoop(com.sun.source.tree.EnhancedForLoopTree tree, java.lang.Void p)
Case 2: Check for implicit.iterator
call.java.lang.Void
visitForLoop(com.sun.source.tree.ForLoopTree tree, java.lang.Void p)
java.lang.Void
visitIf(com.sun.source.tree.IfTree tree, java.lang.Void p)
java.lang.Void
visitInstanceOf(com.sun.source.tree.InstanceOfTree tree, java.lang.Void p)
java.lang.Void
visitMemberSelect(com.sun.source.tree.MemberSelectTree tree, java.lang.Void p)
Case 1: Check for null dereferencing.java.lang.Void
visitMethod(com.sun.source.tree.MethodTree tree, java.lang.Void p)
Checks that the method obeys override and subtype rules to all overridden methods.java.lang.Void
visitMethodInvocation(com.sun.source.tree.MethodInvocationTree tree, java.lang.Void p)
Performs a method invocation check.java.lang.Void
visitNewArray(com.sun.source.tree.NewArrayTree tree, java.lang.Void p)
java.lang.Void
visitNewClass(com.sun.source.tree.NewClassTree tree, java.lang.Void p)
Performs a new class invocation check.java.lang.Void
visitSwitch(com.sun.source.tree.SwitchTree tree, java.lang.Void p)
java.lang.Void
visitSynchronized(com.sun.source.tree.SynchronizedTree tree, java.lang.Void p)
Case 5: Check for synchronizing locks.java.lang.Void
visitTypeCast(com.sun.source.tree.TypeCastTree tree, java.lang.Void p)
Case 7: unboxing case: casting to a primitive.java.lang.Void
visitUnary(com.sun.source.tree.UnaryTree tree, java.lang.Void p)
Case 7: unboxing case: primitive operation.java.lang.Void
visitWhileLoop(com.sun.source.tree.WhileLoopTree tree, java.lang.Void p)
-
Methods inherited from class org.checkerframework.common.basetype.BaseTypeVisitor
checkAccess, checkAccessAllowed, checkArguments, checkArrayInitialization, checkConditionalPostcondition, checkConstructorInvocation, checkContract, checkDefaultConstructor, checkEnclosingExpr, checkExplicitAnnotationsOnIntersectionBounds, checkExtendsAndImplements, checkExtendsOrImplements, checkFieldInvariantDeclarations, checkForPolymorphicQualifiers, checkForPolymorphicQualifiers, checkMethodReferenceAsOverride, checkOverride, checkOverride, checkPostcondition, checkPreconditions, checkPurity, checkQualifierParameter, checkSuperConstructorCall, checkThisConstructorCall, checkTypeArguments, checkTypecastRedundancy, checkTypecastSafety, checkVarargs, commonAssignmentCheckEndDiagnostic, commonAssignmentCheckEndDiagnostic, commonAssignmentCheckStartDiagnostic, createOverrideChecker, createQualAllowedLocations, createTypeFactoryPublic, enclosingMemberSelect, enclosingStatement, getExceptionParameterLowerBoundAnnotations, getThrowUpperBoundAnnotations, getTypeFactory, isTypeCastSafe, isValidUse, isValidUse, reportCommonAssignmentError, reportMethodInvocabilityError, reportPurityErrors, scan, setRoot, shouldSkipUses, shouldWarnAboutIrrelevantJavaTypes, skipReceiverSubtypeCheck, testAnnotationInsertion, testJointJavacJavaParserVisitor, testTypevarContainment, typeCheckVectorCopyIntoArgument, validateTargetLocation, validateType, validateTypeOf, validateVariablesTargetLocation, visitAnnotatedType, visitAssignment, visitCatch, visitClass, visitCompilationUnit, visitIdentifier, visitLambdaExpression, visitMemberReference, visitReturn, visitSwitchExpression17, visitThrow, visitTypeParameter, visitVariable, warnAboutIrrelevantJavaTypes, warnRedundantAnnotations
-
Methods inherited from class org.checkerframework.framework.source.SourceVisitor
visit
-
Methods inherited from class com.sun.source.util.TreeScanner
reduce, scan, visitArrayType, visitBlock, visitBreak, visitCase, visitContinue, visitEmptyStatement, visitErroneous, visitExports, visitExpressionStatement, visitImport, visitIntersectionType, visitLabeledStatement, visitLiteral, visitModifiers, visitModule, visitOpens, visitOther, visitPackage, visitParameterizedType, visitParenthesized, visitPrimitiveType, visitProvides, visitRequires, visitTry, visitUnionType, visitUses, visitWildcard
-
-
-
-
Constructor Detail
-
NullnessNoInitVisitor
public NullnessNoInitVisitor(BaseTypeChecker checker)
Create a new NullnessVisitor.- Parameters:
checker
- the checker to which this visitor belongs
-
-
Method Detail
-
createTypeFactory
public NullnessNoInitAnnotatedTypeFactory createTypeFactory()
Description copied from class:BaseTypeVisitor
Constructs an instance of the appropriate type factory for the implemented type system.The default implementation uses the checker naming convention to create the appropriate type factory. If no factory is found, it returns
BaseAnnotatedTypeFactory
. It reflectively invokes the constructor that accepts this checker and compilation unit tree (in that order) as arguments.Subclasses have to override this method to create the appropriate visitor if they do not follow the checker naming convention.
- Overrides:
createTypeFactory
in classBaseTypeVisitor<NullnessNoInitAnnotatedTypeFactory>
- Returns:
- the appropriate type factory
-
isValidUse
public boolean isValidUse(AnnotatedTypeMirror.AnnotatedPrimitiveType type, com.sun.source.tree.Tree tree)
Description copied from class:BaseTypeVisitor
Tests that the qualifiers present on the primitive type are valid.- Overrides:
isValidUse
in classBaseTypeVisitor<NullnessNoInitAnnotatedTypeFactory>
- Parameters:
type
- the use of the primitive typetree
- the tree where the type is used- Returns:
- true if the type is a valid use of the primitive type
-
checkConstructorResult
protected void checkConstructorResult(AnnotatedTypeMirror.AnnotatedExecutableType constructorType, javax.lang.model.element.ExecutableElement constructorElement)
Description copied from class:BaseTypeVisitor
Issue a warning if the result type of the constructor declaration is not top. If it is a supertype of the class, then a type.invalid.conflicting.annos error will also be issued byBaseTypeVisitor.isValidUse(AnnotatedTypeMirror.AnnotatedDeclaredType,AnnotatedTypeMirror.AnnotatedDeclaredType,Tree)
.- Overrides:
checkConstructorResult
in classBaseTypeVisitor<NullnessNoInitAnnotatedTypeFactory>
- Parameters:
constructorType
- the AnnotatedExecutableType for the constructorconstructorElement
- the element that declares the constructor
-
checkThisOrSuperConstructorCall
protected void checkThisOrSuperConstructorCall(com.sun.source.tree.MethodInvocationTree superCall, @CompilerMessageKey java.lang.String errorKey)
Description copied from class:BaseTypeVisitor
Checks that the following rule is satisfied: The type on a constructor declaration must be a supertype of the return type of "this()" or "super()" invocation within that constructor.- Overrides:
checkThisOrSuperConstructorCall
in classBaseTypeVisitor<NullnessNoInitAnnotatedTypeFactory>
- Parameters:
superCall
- the AST node for the constructor callerrorKey
- the error message key to use if the check fails
-
commonAssignmentCheck
protected boolean commonAssignmentCheck(com.sun.source.tree.Tree varTree, com.sun.source.tree.ExpressionTree valueExp, @CompilerMessageKey java.lang.String errorKey, java.lang.Object... extraArgs)
Description copied from class:BaseTypeVisitor
Checks the validity of an assignment (or pseudo-assignment) from a value to a variable and emits an error message (through the compiler's messaging interface) if it is not valid.- Overrides:
commonAssignmentCheck
in classBaseTypeVisitor<NullnessNoInitAnnotatedTypeFactory>
- Parameters:
varTree
- the AST node for the lvalue (usually a variable)valueExp
- the AST node for the rvalue (the new value)errorKey
- the error message key to use if the check failsextraArgs
- arguments to the error message key, before "found" and "expected" types- Returns:
- true if the check succeeds, false if an error message was issued
-
commonAssignmentCheck
protected boolean commonAssignmentCheck(AnnotatedTypeMirror varType, com.sun.source.tree.ExpressionTree valueExp, @CompilerMessageKey java.lang.String errorKey, java.lang.Object... extraArgs)
Description copied from class:BaseTypeVisitor
Checks the validity of an assignment (or pseudo-assignment) from a value to a variable and emits an error message (through the compiler's messaging interface) if it is not valid.- Overrides:
commonAssignmentCheck
in classBaseTypeVisitor<NullnessNoInitAnnotatedTypeFactory>
- Parameters:
varType
- the annotated type for the lvalue (usually a variable)valueExp
- the AST node for the rvalue (the new value)errorKey
- the error message key to use if the check failsextraArgs
- arguments to the error message key, before "found" and "expected" types- Returns:
- true if the check succeeds, false if an error message was issued
-
commonAssignmentCheck
@FormatMethod protected boolean commonAssignmentCheck(AnnotatedTypeMirror varType, AnnotatedTypeMirror valueType, com.sun.source.tree.Tree valueTree, @CompilerMessageKey java.lang.String errorKey, java.lang.Object... extraArgs)
Description copied from class:BaseTypeVisitor
Checks the validity of an assignment (or pseudo-assignment) from a value to a variable and emits an error message (through the compiler's messaging interface) if it is not valid.- Overrides:
commonAssignmentCheck
in classBaseTypeVisitor<NullnessNoInitAnnotatedTypeFactory>
- Parameters:
varType
- the annotated type of the variablevalueType
- the annotated type of the valuevalueTree
- the location to use when reporting the error messageerrorKey
- the error message key to use if the check failsextraArgs
- arguments to the error message key, before "found" and "expected" types- Returns:
- true if the check succeeds, false if an error message was issued
-
visitMemberSelect
public java.lang.Void visitMemberSelect(com.sun.source.tree.MemberSelectTree tree, java.lang.Void p)
Case 1: Check for null dereferencing.- Specified by:
visitMemberSelect
in interfacecom.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
- Overrides:
visitMemberSelect
in classcom.sun.source.util.TreeScanner<java.lang.Void,java.lang.Void>
-
visitEnhancedForLoop
public java.lang.Void visitEnhancedForLoop(com.sun.source.tree.EnhancedForLoopTree tree, java.lang.Void p)
Case 2: Check for implicit.iterator
call.- Specified by:
visitEnhancedForLoop
in interfacecom.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
- Overrides:
visitEnhancedForLoop
in classBaseTypeVisitor<NullnessNoInitAnnotatedTypeFactory>
-
visitArrayAccess
public java.lang.Void visitArrayAccess(com.sun.source.tree.ArrayAccessTree tree, java.lang.Void p)
Case 3: Check for array dereferencing.- Specified by:
visitArrayAccess
in interfacecom.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
- Overrides:
visitArrayAccess
in classcom.sun.source.util.TreeScanner<java.lang.Void,java.lang.Void>
-
visitNewArray
public java.lang.Void visitNewArray(com.sun.source.tree.NewArrayTree tree, java.lang.Void p)
- Specified by:
visitNewArray
in interfacecom.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
- Overrides:
visitNewArray
in classBaseTypeVisitor<NullnessNoInitAnnotatedTypeFactory>
-
checkThrownExpression
protected void checkThrownExpression(com.sun.source.tree.ThrowTree tree)
Case 4: Check for thrown exception nullness.- Overrides:
checkThrownExpression
in classBaseTypeVisitor<NullnessNoInitAnnotatedTypeFactory>
- Parameters:
tree
- a ThrowTree to check
-
visitSynchronized
public java.lang.Void visitSynchronized(com.sun.source.tree.SynchronizedTree tree, java.lang.Void p)
Case 5: Check for synchronizing locks.- Specified by:
visitSynchronized
in interfacecom.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
- Overrides:
visitSynchronized
in classcom.sun.source.util.TreeScanner<java.lang.Void,java.lang.Void>
-
visitAssert
public java.lang.Void visitAssert(com.sun.source.tree.AssertTree tree, java.lang.Void p)
- Specified by:
visitAssert
in interfacecom.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
- Overrides:
visitAssert
in classcom.sun.source.util.TreeScanner<java.lang.Void,java.lang.Void>
-
visitIf
public java.lang.Void visitIf(com.sun.source.tree.IfTree tree, java.lang.Void p)
- Specified by:
visitIf
in interfacecom.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
- Overrides:
visitIf
in classcom.sun.source.util.TreeScanner<java.lang.Void,java.lang.Void>
-
visitInstanceOf
public java.lang.Void visitInstanceOf(com.sun.source.tree.InstanceOfTree tree, java.lang.Void p)
- Specified by:
visitInstanceOf
in interfacecom.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
- Overrides:
visitInstanceOf
in classBaseTypeVisitor<NullnessNoInitAnnotatedTypeFactory>
-
checkForRedundantTests
protected void checkForRedundantTests(com.sun.source.tree.BinaryTree tree)
Reports an error if a comparison of a @NonNull expression with the null literal is performed.- Parameters:
tree
- a tree that might be a comparison of a @NonNull expression with the null literal
-
visitBinary
public java.lang.Void visitBinary(com.sun.source.tree.BinaryTree tree, java.lang.Void p)
Case 6: Check for redundant nullness tests Case 7: unboxing case: primitive operations.- Specified by:
visitBinary
in interfacecom.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
- Overrides:
visitBinary
in classcom.sun.source.util.TreeScanner<java.lang.Void,java.lang.Void>
-
visitUnary
public java.lang.Void visitUnary(com.sun.source.tree.UnaryTree tree, java.lang.Void p)
Case 7: unboxing case: primitive operation.- Specified by:
visitUnary
in interfacecom.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
- Overrides:
visitUnary
in classBaseTypeVisitor<NullnessNoInitAnnotatedTypeFactory>
-
visitCompoundAssignment
public java.lang.Void visitCompoundAssignment(com.sun.source.tree.CompoundAssignmentTree tree, java.lang.Void p)
Case 7: unboxing case: primitive operation.- Specified by:
visitCompoundAssignment
in interfacecom.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
- Overrides:
visitCompoundAssignment
in classBaseTypeVisitor<NullnessNoInitAnnotatedTypeFactory>
-
visitTypeCast
public java.lang.Void visitTypeCast(com.sun.source.tree.TypeCastTree tree, java.lang.Void p)
Case 7: unboxing case: casting to a primitive.- Specified by:
visitTypeCast
in interfacecom.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
- Overrides:
visitTypeCast
in classBaseTypeVisitor<NullnessNoInitAnnotatedTypeFactory>
-
visitMethod
public java.lang.Void visitMethod(com.sun.source.tree.MethodTree tree, java.lang.Void p)
Description copied from class:BaseTypeVisitor
Checks that the method obeys override and subtype rules to all overridden methods. (Uses the pseudo-assignment logic to do so.)The override rule specifies that a method, m1, may override a method m2 only if:
- m1 return type is a subtype of m2
- m1 receiver type is a supertype of m2
- m1 parameters are supertypes of corresponding m2 parameters
- Specified by:
visitMethod
in interfacecom.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
- Overrides:
visitMethod
in classBaseTypeVisitor<NullnessNoInitAnnotatedTypeFactory>
-
visitMethodInvocation
public java.lang.Void visitMethodInvocation(com.sun.source.tree.MethodInvocationTree tree, java.lang.Void p)
Description copied from class:BaseTypeVisitor
Performs a method invocation check.An invocation of a method, m, on the receiver, r is valid only if:
- passed arguments are subtypes of corresponding m parameters
- r is a subtype of m receiver type
- if m is generic, passed type arguments are subtypes of m type variables
- Specified by:
visitMethodInvocation
in interfacecom.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
- Overrides:
visitMethodInvocation
in classBaseTypeVisitor<NullnessNoInitAnnotatedTypeFactory>
-
processClassTree
public void processClassTree(com.sun.source.tree.ClassTree classTree)
Description copied from class:BaseTypeVisitor
Type-check classTree. Subclasses should override this method instead ofBaseTypeVisitor.visitClass(ClassTree, Void)
.- Overrides:
processClassTree
in classBaseTypeVisitor<NullnessNoInitAnnotatedTypeFactory>
- Parameters:
classTree
- class to check
-
checkMethodInvocability
protected void checkMethodInvocability(AnnotatedTypeMirror.AnnotatedExecutableType method, com.sun.source.tree.MethodInvocationTree tree)
Description copied from class:BaseTypeVisitor
Tests whether the method can be invoked using the receiver of the 'tree' 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. This behavior can be specialized by overriding skipReceiverSubtypeCheck.
- Overrides:
checkMethodInvocability
in classBaseTypeVisitor<NullnessNoInitAnnotatedTypeFactory>
- Parameters:
method
- the type of the invoked methodtree
- the method invocation tree
-
visitSwitch
public java.lang.Void visitSwitch(com.sun.source.tree.SwitchTree tree, java.lang.Void p)
- Specified by:
visitSwitch
in interfacecom.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
- Overrides:
visitSwitch
in classcom.sun.source.util.TreeScanner<java.lang.Void,java.lang.Void>
-
visitForLoop
public java.lang.Void visitForLoop(com.sun.source.tree.ForLoopTree tree, java.lang.Void p)
- Specified by:
visitForLoop
in interfacecom.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
- Overrides:
visitForLoop
in classcom.sun.source.util.TreeScanner<java.lang.Void,java.lang.Void>
-
visitNewClass
public java.lang.Void visitNewClass(com.sun.source.tree.NewClassTree tree, java.lang.Void p)
Description copied from class:BaseTypeVisitor
Performs a new class invocation check.An invocation of a constructor, c, is valid only if:
- passed arguments are subtypes of corresponding c parameters
- if c is generic, passed type arguments are subtypes of c type variables
- Specified by:
visitNewClass
in interfacecom.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
- Overrides:
visitNewClass
in classBaseTypeVisitor<NullnessNoInitAnnotatedTypeFactory>
-
visitWhileLoop
public java.lang.Void visitWhileLoop(com.sun.source.tree.WhileLoopTree tree, java.lang.Void p)
- Specified by:
visitWhileLoop
in interfacecom.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
- Overrides:
visitWhileLoop
in classcom.sun.source.util.TreeScanner<java.lang.Void,java.lang.Void>
-
visitDoWhileLoop
public java.lang.Void visitDoWhileLoop(com.sun.source.tree.DoWhileLoopTree tree, java.lang.Void p)
- Specified by:
visitDoWhileLoop
in interfacecom.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
- Overrides:
visitDoWhileLoop
in classcom.sun.source.util.TreeScanner<java.lang.Void,java.lang.Void>
-
visitConditionalExpression
public java.lang.Void visitConditionalExpression(com.sun.source.tree.ConditionalExpressionTree tree, java.lang.Void p)
Description copied from class:BaseTypeVisitor
If the computation of the type of the ConditionalExpressionTree in org.checkerframework.framework.type.TypeFromTree.TypeFromExpression.visitConditionalExpression(ConditionalExpressionTree, AnnotatedTypeFactory) is correct, the following checks are redundant. However, let's add another failsafe guard and do the checks.- Specified by:
visitConditionalExpression
in interfacecom.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
- Overrides:
visitConditionalExpression
in classBaseTypeVisitor<NullnessNoInitAnnotatedTypeFactory>
-
checkExceptionParameter
protected void checkExceptionParameter(com.sun.source.tree.CatchTree tree)
Description copied from class:BaseTypeVisitor
Issue error if the exception parameter is not a supertype of the annotation specified byBaseTypeVisitor.getExceptionParameterLowerBoundAnnotations()
, which is top by default.Subclasses may override this method to change the behavior of this check. Subclasses wishing to enforce that exception parameter be annotated with other annotations can just override
BaseTypeVisitor.getExceptionParameterLowerBoundAnnotations()
.- Overrides:
checkExceptionParameter
in classBaseTypeVisitor<NullnessNoInitAnnotatedTypeFactory>
- Parameters:
tree
- a CatchTree to check
-
visitAnnotation
public java.lang.Void visitAnnotation(com.sun.source.tree.AnnotationTree tree, java.lang.Void p)
Description copied from class:BaseTypeVisitor
Ensure that the annotation arguments comply to their declarations. This needs some special casing, as annotation arguments form special trees.- Specified by:
visitAnnotation
in interfacecom.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
- Overrides:
visitAnnotation
in classBaseTypeVisitor<NullnessNoInitAnnotatedTypeFactory>
-
visitAnnotatedType
public void visitAnnotatedType(@Nullable java.util.List<? extends com.sun.source.tree.AnnotationTree> annoTrees, com.sun.source.tree.Tree typeTree)
Description copied from class:BaseTypeVisitor
Checks an annotated type. Invoked byBaseTypeVisitor.visitAnnotatedType(AnnotatedTypeTree, Void)
,BaseTypeVisitor.visitVariable(com.sun.source.tree.VariableTree, java.lang.Void)
, andBaseTypeVisitor.visitMethod(com.sun.source.tree.MethodTree, java.lang.Void)
. Exists to prevent code duplication among the three. Checking invisitVariable
andvisitMethod
is needed because there isn't an AnnotatedTypeTree within a variable declaration or for a method return type -- all the annotations are attached to the VariableTree or MethodTree, respectively.- Overrides:
visitAnnotatedType
in classBaseTypeVisitor<NullnessNoInitAnnotatedTypeFactory>
- Parameters:
annoTrees
- annotations written before a variable/method declaration, if this type is from one; null otherwise. This might contain type annotations that the Java parser attached to the declaration rather than to the type.typeTree
- the type that any type annotations in annoTrees apply to
-
createTypeValidator
protected TypeValidator createTypeValidator()
- Overrides:
createTypeValidator
in classBaseTypeVisitor<NullnessNoInitAnnotatedTypeFactory>
-
-