public class ValueVisitor extends BaseTypeVisitor<ValueAnnotatedTypeFactory>
BaseTypeVisitor.OverrideCheckeratypeFactory, checker, DETERMINISTIC, inferPurity, methodTree, positions, PURE, SIDE_EFFECT_FREE, TARGET, targetValueElement, typeValidator, unusedWhenElementelements, root, trees, treesWithSuppressWarnings, types| Constructor and Description |
|---|
ValueVisitor(BaseTypeChecker checker) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
checkOverride(MethodTree overriderTree,
AnnotatedTypeMirror.AnnotatedExecutableType overrider,
AnnotatedTypeMirror.AnnotatedDeclaredType overridingType,
AnnotatedTypeMirror.AnnotatedExecutableType overridden,
AnnotatedTypeMirror.AnnotatedDeclaredType overriddenType)
Return types for methods that are annotated with
@IntRangeFromX annotations need to be
replaced with @UnknownVal. |
protected void |
commonAssignmentCheck(AnnotatedTypeMirror varType,
AnnotatedTypeMirror valueType,
Tree valueTree,
@CompilerMessageKey String errorKey,
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 void |
commonAssignmentCheck(AnnotatedTypeMirror varType,
ExpressionTree valueExp,
@CompilerMessageKey String errorKey,
Object... extraArgs)
ValueVisitor overrides this method so that it does not have to check variables annotated with
the
IntRangeFromPositive annotation, the IntRangeFromNonNegative annotation, or
the IntRangeFromGTENegativeOne annotation. |
protected ValueAnnotatedTypeFactory |
createTypeFactory()
Constructs an instance of the appropriate type factory for the implemented type system.
|
boolean |
validateType(Tree tree,
AnnotatedTypeMirror type)
Overridden to issue errors at the appropriate place if an
IntRange or ArrayLenRange annotation has from > to. |
Void |
visitAnnotation(AnnotationTree node,
Void p)
Warns about malformed constant-value annotations.
|
Void |
visitMethod(MethodTree node,
Void p)
Checks that the method obeys override and subtype rules to all overridden methods.
|
Void |
visitTypeCast(TypeCastTree node,
Void p) |
checkAccess, checkAccessAllowed, checkArguments, checkArrayInitialization, checkConditionalPostcondition, checkConstructorInvocation, checkConstructorResult, checkContract, checkDefaultConstructor, checkExceptionParameter, checkExplicitAnnotationsOnIntersectionBounds, checkExtendsImplements, checkFieldInvariantDeclarations, checkForPolymorphicQualifiers, checkForPolymorphicQualifiers, checkMethodInvocability, checkMethodReferenceAsOverride, checkOverride, checkPostcondition, checkPreconditions, checkPurity, checkQualifierParameter, checkSuperConstructorCall, checkThisConstructorCall, checkThisOrSuperConstructorCall, checkThrownExpression, checkTypeArguments, checkTypecastRedundancy, checkTypecastSafety, checkVarargs, commonAssignmentCheck, commonAssignmentCheckEndDiagnostic, commonAssignmentCheckEndDiagnostic, commonAssignmentCheckStartDiagnostic, createOverrideChecker, createTypeFactoryPublic, createTypeValidator, enclosingMemberSelect, enclosingStatement, getExceptionParameterLowerBoundAnnotations, getThrowUpperBoundAnnotations, getTypeFactory, isTypeCastSafe, isValidUse, isValidUse, isValidUse, processClassTree, reportMethodInvocabilityError, reportPurityErrors, scan, setRoot, shouldSkipUses, shouldWarnAboutIrrelevantJavaTypes, skipReceiverSubtypeCheck, testAnnotationInsertion, testJointJavacJavaParserVisitor, testTypevarContainment, typeCheckVectorCopyIntoArgument, validateTypeOf, visitAnnotatedType, visitAnnotatedType, visitAssignment, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitEnhancedForLoop, visitIdentifier, visitInstanceOf, visitLambdaExpression, visitMemberReference, visitMethodInvocation, visitNewArray, visitNewClass, visitReturn, visitSwitchExpression17, visitThrow, visitTypeParameter, visitUnary, visitVariable, warnAboutIrrelevantJavaTypesvisitgetCurrentPath, scanreduce, scan, visitArrayAccess, visitArrayType, visitAssert, visitBinary, visitBlock, visitBreak, visitCase, visitContinue, visitDoWhileLoop, visitEmptyStatement, visitErroneous, visitExports, visitExpressionStatement, visitForLoop, visitIf, visitImport, visitIntersectionType, visitLabeledStatement, visitLiteral, visitMemberSelect, visitModifiers, visitModule, visitOpens, visitOther, visitPackage, visitParameterizedType, visitParenthesized, visitPrimitiveType, visitProvides, visitRequires, visitSwitch, visitSynchronized, visitTry, visitUnionType, visitUses, visitWhileLoop, visitWildcardpublic ValueVisitor(BaseTypeChecker checker)
protected void commonAssignmentCheck(AnnotatedTypeMirror varType, ExpressionTree valueExp, @CompilerMessageKey String errorKey, Object... extraArgs)
IntRangeFromPositive annotation, the IntRangeFromNonNegative annotation, or
the IntRangeFromGTENegativeOne annotation. This annotation is only introduced by the
Index Checker's lower bound annotations. It is safe to defer checking of these values to the
Index Checker because this is only introduced for explicitly-written org.checkerframework.checker.index.qual.Positive, explicitly-written org.checkerframework.checker.index.qual.NonNegative, and explicitly-written org.checkerframework.checker.index.qual.GTENegativeOne annotations, which must be checked by
the Lower Bound Checker.commonAssignmentCheck in class BaseTypeVisitor<ValueAnnotatedTypeFactory>varType - the annotated type of 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@FormatMethod protected void commonAssignmentCheck(AnnotatedTypeMirror varType, AnnotatedTypeMirror valueType, Tree valueTree, @CompilerMessageKey String errorKey, Object... extraArgs)
BaseTypeVisitorcommonAssignmentCheck in class BaseTypeVisitor<ValueAnnotatedTypeFactory>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" typesprotected boolean checkOverride(MethodTree overriderTree, AnnotatedTypeMirror.AnnotatedExecutableType overrider, AnnotatedTypeMirror.AnnotatedDeclaredType overridingType, AnnotatedTypeMirror.AnnotatedExecutableType overridden, AnnotatedTypeMirror.AnnotatedDeclaredType overriddenType)
@IntRangeFromX annotations need to be
replaced with @UnknownVal. See the documentation on commonAssignmentCheck.
A separate override is necessary because checkOverride doesn't actually use the commonAssignmentCheck.
checkOverride in class BaseTypeVisitor<ValueAnnotatedTypeFactory>overriderTree - declaration tree of overriding methodoverrider - type of the overriding methodoverridingType - type of overriding classoverridden - type of overridden methodoverriddenType - type of overridden classBaseTypeVisitor.checkOverride(MethodTree, AnnotatedTypeMirror.AnnotatedDeclaredType,
AnnotatedTypeMirror.AnnotatedExecutableType, AnnotatedTypeMirror.AnnotatedDeclaredType)protected ValueAnnotatedTypeFactory createTypeFactory()
BaseTypeVisitorThe 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.
createTypeFactory in class BaseTypeVisitor<ValueAnnotatedTypeFactory>public Void visitAnnotation(AnnotationTree node, Void p)
Issues an error if any @IntRange annotation has its 'from' value greater than 'to' value.
Issues an error if any constant-value annotation has no arguments.
Issues a warning if any constant-value annotation has > MAX_VALUES arguments.
Issues a warning if any @ArrayLen/@ArrayLenRange annotations contain a negative array length.
Issues a warning if any @MatchesRegex annotation contains an invalid regular expression.
visitAnnotation in interface TreeVisitor<Void,Void>visitAnnotation in class BaseTypeVisitor<ValueAnnotatedTypeFactory>public Void visitTypeCast(TypeCastTree node, Void p)
visitTypeCast in interface TreeVisitor<Void,Void>visitTypeCast in class BaseTypeVisitor<ValueAnnotatedTypeFactory>public boolean validateType(Tree tree, AnnotatedTypeMirror type)
IntRange or ArrayLenRange annotation has from > to. from > to either indicates a user
error when writing an annotation or an error in the checker's implementation, as from
should always be <= to. Note that additional checks are performed in visitAnnotation(AnnotationTree, Void).validateType in class BaseTypeVisitor<ValueAnnotatedTypeFactory>tree - the type tree supplied by the usertype - the type corresponding to treevisitAnnotation(AnnotationTree, Void)public Void visitMethod(MethodTree node, Void p)
BaseTypeVisitorThe override rule specifies that a method, m1, may override a method m2 only if:
visitMethod in interface TreeVisitor<Void,Void>visitMethod in class BaseTypeVisitor<ValueAnnotatedTypeFactory>