Class ValueVisitor
- All Implemented Interfaces:
- TreeVisitor<Void,- Void> 
- 
Nested Class SummaryNested classes/interfaces inherited from class org.checkerframework.common.basetype.BaseTypeVisitorBaseTypeVisitor.OverrideChecker
- 
Field SummaryFields inherited from class org.checkerframework.common.basetype.BaseTypeVisitoratypeFactory, checker, DETERMINISTIC, IMPURE, methodTree, positions, PURE, qualHierarchy, showchecks, SIDE_EFFECT_FREE, TARGET, targetValueElement, typeHierarchy, typeValidator, unusedWhenElementFields inherited from class org.checkerframework.framework.source.SourceVisitorelements, root, trees, treesWithSuppressWarnings, types
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected booleancheckOverride(MethodTree overriderTree, AnnotatedTypeMirror.AnnotatedExecutableType overrider, AnnotatedTypeMirror.AnnotatedDeclaredType overridingType, AnnotatedTypeMirror.AnnotatedExecutableType overridden, AnnotatedTypeMirror.AnnotatedDeclaredType overriddenType) Return types for methods that are annotated with@IntRangeFromXannotations need to be replaced with@UnknownVal.protected booleancommonAssignmentCheck(AnnotatedTypeMirror varType, ExpressionTree valueExp, @CompilerMessageKey String errorKey, Object... extraArgs) ValueVisitor overrides this method so that it does not have to check variables annotated with theIntRangeFromPositiveannotation, theIntRangeFromNonNegativeannotation, or theIntRangeFromGTENegativeOneannotation.protected booleancommonAssignmentCheck(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 ValueAnnotatedTypeFactoryConstructs an instance of the appropriate type factory for the implemented type system.protected booleanisTypeCastSafe(AnnotatedTypeMirror castType, AnnotatedTypeMirror exprType) Returns true if the cast is safe.booleanvalidateType(Tree tree, AnnotatedTypeMirror type) Overridden to issue errors at the appropriate place if anIntRangeorArrayLenRangeannotation hasfrom > to.visitAnnotation(AnnotationTree tree, Void p) Warns about malformed constant-value annotations.visitMethod(MethodTree tree, Void p) Checks that the method or constructor obeys override and subtype rules to all overridden methods.visitTypeCast(TypeCastTree tree, Void p) Methods inherited from class org.checkerframework.common.basetype.BaseTypeVisitorcheckAccess, checkAccessAllowed, checkArguments, checkArrayInitialization, checkConditionalPostcondition, checkConstructorInvocation, checkConstructorResult, checkContract, checkDefaultConstructor, checkExceptionParameter, checkExplicitAnnotationsOnIntersectionBounds, checkExtendsAndImplements, checkExtendsOrImplements, 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, 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, warnAboutIrrelevantJavaTypes, warnRedundantAnnotationsMethods inherited from class org.checkerframework.framework.source.SourceVisitorvisitMethods inherited from class com.sun.source.util.TreePathScannergetCurrentPath, scanMethods inherited from class com.sun.source.util.TreeScannerreduce, scan, visitArrayAccess, visitArrayType, visitAssert, visitBinary, visitBindingPattern, visitBlock, visitBreak, visitCase, visitContinue, visitDefaultCaseLabel, visitDoWhileLoop, visitEmptyStatement, visitErroneous, visitExports, visitExpressionStatement, visitForLoop, visitGuardedPattern, visitIf, visitImport, visitIntersectionType, visitLabeledStatement, visitLiteral, visitMemberSelect, visitModifiers, visitModule, visitOpens, visitOther, visitPackage, visitParameterizedType, visitParenthesized, visitParenthesizedPattern, visitPrimitiveType, visitProvides, visitRequires, visitSwitch, visitSwitchExpression, visitSynchronized, visitTry, visitUnionType, visitUses, visitWhileLoop, visitWildcard, visitYield
- 
Constructor Details- 
ValueVisitor
 
- 
- 
Method Details- 
commonAssignmentCheckprotected boolean 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 theIntRangeFromPositiveannotation, theIntRangeFromNonNegativeannotation, or theIntRangeFromGTENegativeOneannotation. 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-writtenorg.checkerframework.checker.index.qual.Positive, explicitly-writtenorg.checkerframework.checker.index.qual.NonNegative, and explicitly-writtenorg.checkerframework.checker.index.qual.GTENegativeOneannotations, which must be checked by the Lower Bound Checker.- Overrides:
- commonAssignmentCheckin class- BaseTypeVisitor<ValueAnnotatedTypeFactory>
- Parameters:
- 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 fails
- extraArgs- 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, Tree valueTree, @CompilerMessageKey String errorKey, Object... extraArgs) Description copied from class:BaseTypeVisitorChecks 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:
- commonAssignmentCheckin class- BaseTypeVisitor<ValueAnnotatedTypeFactory>
- Parameters:
- varType- the annotated type of the variable
- valueType- the annotated type of the value
- valueTree- the location to use when reporting the error message
- errorKey- the error message key to use if the check fails
- extraArgs- arguments to the error message key, before "found" and "expected" types
- Returns:
- true if the check succeeds, false if an error message was issued
 
- 
checkOverrideprotected boolean checkOverride(MethodTree overriderTree, AnnotatedTypeMirror.AnnotatedExecutableType overrider, AnnotatedTypeMirror.AnnotatedDeclaredType overridingType, AnnotatedTypeMirror.AnnotatedExecutableType overridden, AnnotatedTypeMirror.AnnotatedDeclaredType overriddenType) Return types for methods that are annotated with@IntRangeFromXannotations need to be replaced with@UnknownVal. See the documentation oncommonAssignmentCheck.A separate override is necessary because checkOverride doesn't actually use the commonAssignmentCheck. - Overrides:
- checkOverridein class- BaseTypeVisitor<ValueAnnotatedTypeFactory>
- Parameters:
- overriderTree- declaration tree of overriding method
- overrider- type of the overriding method
- overridingType- type of overriding class
- overridden- type of overridden method
- overriddenType- type of overridden class
- Returns:
- true if the override is allowed
- See Also:
 
- 
createTypeFactoryDescription copied from class:BaseTypeVisitorConstructs 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:
- createTypeFactoryin class- BaseTypeVisitor<ValueAnnotatedTypeFactory>
- Returns:
- the appropriate type factory
 
- 
visitAnnotationWarns about malformed constant-value annotations.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 or @DoesNotMatchRegex annotation contains an invalid regular expression. - Specified by:
- visitAnnotationin interface- TreeVisitor<Void,- Void> 
- Overrides:
- visitAnnotationin class- BaseTypeVisitor<ValueAnnotatedTypeFactory>
 
- 
visitTypeCast- Specified by:
- visitTypeCastin interface- TreeVisitor<Void,- Void> 
- Overrides:
- visitTypeCastin class- BaseTypeVisitor<ValueAnnotatedTypeFactory>
 
- 
isTypeCastSafeDescription copied from class:BaseTypeVisitorReturns true if the cast is safe.Only primary qualifiers are checked unless the command line option "checkCastElementType" is supplied. - Overrides:
- isTypeCastSafein class- BaseTypeVisitor<ValueAnnotatedTypeFactory>
- Parameters:
- castType- annotated type of the cast
- exprType- annotated type of the casted expression
- Returns:
- true if the type cast is safe, false otherwise
 
- 
validateTypeOverridden to issue errors at the appropriate place if anIntRangeorArrayLenRangeannotation hasfrom > to.from > toeither indicates a user error when writing an annotation or an error in the checker's implementation, asfromshould always be<= to. Note that additional checks are performed invisitAnnotation(AnnotationTree, Void).- Overrides:
- validateTypein class- BaseTypeVisitor<ValueAnnotatedTypeFactory>
- Parameters:
- tree- the type tree supplied by the user
- type- the type corresponding to tree
- Returns:
- true if the type is valid
- See Also:
 
- 
visitMethodDescription copied from class:BaseTypeVisitorChecks that the method or constructor 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:
- visitMethodin interface- TreeVisitor<Void,- Void> 
- Overrides:
- visitMethodin class- BaseTypeVisitor<ValueAnnotatedTypeFactory>
 
 
-