Class FenumVisitor
- All Implemented Interfaces:
TreeVisitor<Void,Void>
-
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
assumePureGetters, atypeFactory, checker, DETERMINISTIC, ignoreTargetLocations, IMPURE, methodTree, positions, PURE, qualAllowedLocations, qualHierarchy, showchecks, SIDE_EFFECT_FREE, TARGET, targetValueElement, typeHierarchy, typeValidator, unusedWhenElement, warnRedundantAnnotationsFields inherited from class org.checkerframework.framework.source.SourceVisitor
elements, root, trees, treesWithSuppressWarnings, types -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckConstructorInvocation(AnnotatedTypeMirror.AnnotatedDeclaredType dt, AnnotatedTypeMirror.AnnotatedExecutableType constructor, NewClassTree src) Check that the (explicit) annotations on a new class tree are comparable to the result type of the constructor.protected voidcheckConstructorResult(AnnotatedTypeMirror.AnnotatedExecutableType constructorType, ExecutableElement constructorElement) Issue a warning if the result type of the constructor declaration is not top.protected AnnotationMirrorSetReturns a set of AnnotationMirrors that is a lower bound for exception parameters.booleanisValidUse(AnnotatedTypeMirror.AnnotatedDeclaredType declarationType, AnnotatedTypeMirror.AnnotatedDeclaredType useType, Tree tree) Tests that the qualifiers present onuseTypeare valid qualifiers, given the qualifiers on the declaration of the type,declarationType.visitBinary(BinaryTree tree, Void p) visitSwitch(SwitchTree tree, Void p) Methods inherited from class org.checkerframework.common.basetype.BaseTypeVisitor
checkAccess, checkAccessAllowed, checkArguments, checkArrayInitialization, checkConditionalPostcondition, checkContract, checkDefaultConstructor, checkEnclosingExpr, checkExceptionParameter, checkExplicitAnnotationsOnIntersectionBounds, checkExtendsAndImplements, checkExtendsOrImplements, checkFieldInvariantDeclarations, checkMethodInvocability, checkMethodReferenceAsOverride, checkOverride, checkOverride, checkPostcondition, checkPreconditions, checkPurityAnnotations, checkQualifierParameter, checkSuperConstructorCall, checkThisConstructorCall, checkThisOrSuperConstructorCall, checkThrownExpression, checkTypeArguments, checkTypecastRedundancy, checkTypecastSafety, checkVarargs, commonAssignmentCheck, commonAssignmentCheck, commonAssignmentCheck, commonAssignmentCheckEndDiagnostic, commonAssignmentCheckEndDiagnostic, commonAssignmentCheckStartDiagnostic, contractExpressionAndType, createOverrideChecker, createQualAllowedLocations, createTypeFactory, createTypeFactoryPublic, createTypeValidator, enclosingMemberSelect, enclosingStatement, getThrowUpperBoundAnnotations, getTypeFactory, isTypeCastSafe, isValidUse, isValidUse, processClassTree, processMethodTree, reportCommonAssignmentError, reportMethodInvocabilityError, reportPurityErrors, scan, setRoot, shouldSkipUses, shouldWarnAboutIrrelevantJavaTypes, skipReceiverSubtypeCheck, testAnnotationInsertion, testJointJavacJavaParserVisitor, testTypevarContainment, typeCheckVectorCopyIntoArgument, validateTargetLocation, validateType, validateTypeOf, validateVariablesTargetLocation, visitAnnotatedType, visitAnnotatedType, visitAnnotation, visitAssignment, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitEnhancedForLoop, visitIdentifier, visitInstanceOf, visitLambdaExpression, visitMemberReference, visitMethod, visitMethodInvocation, visitNewArray, visitNewClass, visitReturn, visitSwitchExpression17, visitThrow, visitTypeCast, visitTypeParameter, visitUnary, visitVariable, warnAboutIrrelevantJavaTypes, warnInvalidPolymorphicQualifier, warnInvalidPolymorphicQualifier, warnRedundantAnnotationsMethods inherited from class org.checkerframework.framework.source.SourceVisitor
visitMethods inherited from class com.sun.source.util.TreePathScanner
getCurrentPath, scanMethods inherited from class com.sun.source.util.TreeScanner
reduce, scan, visitAnyPattern, visitArrayAccess, visitArrayType, visitAssert, visitBindingPattern, visitBlock, visitBreak, visitCase, visitConstantCaseLabel, visitContinue, visitDeconstructionPattern, visitDefaultCaseLabel, visitDoWhileLoop, visitEmptyStatement, visitErroneous, visitExports, visitExpressionStatement, visitForLoop, visitIf, visitImport, visitIntersectionType, visitLabeledStatement, visitLiteral, visitMemberSelect, visitModifiers, visitModule, visitOpens, visitOther, visitPackage, visitParameterizedType, visitParenthesized, visitPatternCaseLabel, visitPrimitiveType, visitProvides, visitRequires, visitStringTemplate, visitSwitchExpression, visitSynchronized, visitTry, visitUnionType, visitUses, visitWhileLoop, visitWildcard, visitYield
-
Constructor Details
-
FenumVisitor
Creates a Fenum Visitor- Parameters:
checker- the checker
-
-
Method Details
-
visitBinary
- Specified by:
visitBinaryin interfaceTreeVisitor<Void,Void> - Overrides:
visitBinaryin classTreeScanner<Void,Void>
-
visitSwitch
- Specified by:
visitSwitchin interfaceTreeVisitor<Void,Void> - Overrides:
visitSwitchin classTreeScanner<Void,Void>
-
checkConstructorInvocation
protected void checkConstructorInvocation(AnnotatedTypeMirror.AnnotatedDeclaredType dt, AnnotatedTypeMirror.AnnotatedExecutableType constructor, NewClassTree src) Description copied from class:BaseTypeVisitorCheck that the (explicit) annotations on a new class tree are comparable to the result type of the constructor. Issue an error if not.Issue a warning if the annotations on the constructor invocation is a subtype of the constructor result type. This is equivalent to down-casting.
For type checking of the enclosing expression of inner type instantiations, see
BaseTypeVisitor.checkEnclosingExpr(NewClassTree, AnnotatedTypeMirror.AnnotatedExecutableType)- Overrides:
checkConstructorInvocationin classBaseTypeVisitor<FenumAnnotatedTypeFactory>- Parameters:
dt- the AnnotatedDeclaredType of the constructor invocationconstructor- the AnnotatedExecutableType of the constructor declarationsrc- the NewClassTree
-
checkConstructorResult
protected void checkConstructorResult(AnnotatedTypeMirror.AnnotatedExecutableType constructorType, ExecutableElement constructorElement) Description copied from class:BaseTypeVisitorIssue 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:
checkConstructorResultin classBaseTypeVisitor<FenumAnnotatedTypeFactory>- Parameters:
constructorType- the AnnotatedExecutableType for the constructorconstructorElement- the element that declares the constructor
-
getExceptionParameterLowerBoundAnnotations
Description copied from class:BaseTypeVisitorReturns a set of AnnotationMirrors that is a lower bound for exception parameters.This implementation returns top; subclasses can change this behavior.
Note: by default this method is called by
BaseTypeVisitor.getThrowUpperBoundAnnotations(), so that this annotation is enforced.- Overrides:
getExceptionParameterLowerBoundAnnotationsin classBaseTypeVisitor<FenumAnnotatedTypeFactory>- Returns:
- set of annotation mirrors, one per hierarchy, that form a lower bound of annotations that can be written on an exception parameter
-
isValidUse
public boolean isValidUse(AnnotatedTypeMirror.AnnotatedDeclaredType declarationType, AnnotatedTypeMirror.AnnotatedDeclaredType useType, Tree tree) Description copied from class:BaseTypeVisitorTests that the qualifiers present onuseTypeare valid qualifiers, given the qualifiers on the declaration of the type,declarationType.The check is shallow, as it does not descend into generic or array types (i.e. only performing the validity check on the raw type or outermost array dimension).
BaseTypeVisitor.validateTypeOf(Tree)would call this for each type argument or array dimension separately.In most cases,
useTypesimply needs to be a subtype ofdeclarationType. If a type system makes exceptions to this rule, its implementation should override this method.This method is not called if
BaseTypeValidator.shouldCheckTopLevelDeclaredOrPrimitiveType(AnnotatedTypeMirror, Tree)returns false -- by default, it is not called on the top level for locals and expressions. To enforce a type validity property everywhere, override methods such asBaseTypeValidator.visitDeclared(org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType, com.sun.source.tree.Tree)rather than this method.- Overrides:
isValidUsein classBaseTypeVisitor<FenumAnnotatedTypeFactory>- Parameters:
declarationType- the type of the class (TypeElement)useType- the use of the class (instance type)tree- the tree where the type is used- Returns:
- true if the useType is a valid use of elemType
-