Class DefaultForTypeAnnotator
java.lang.Object
org.checkerframework.framework.type.visitor.AnnotatedTypeScanner<Void,Void>
org.checkerframework.framework.type.typeannotator.TypeAnnotator
org.checkerframework.framework.type.typeannotator.DefaultForTypeAnnotator
- All Implemented Interfaces:
AnnotatedTypeVisitor<Void,
Void>
Adds annotations to a type based on the use of a type. This class applies annotations specified
by
DefaultFor
; it is designed to be used in a ListTypeAnnotator
constructed in
GenericAnnotatedTypeFactory.createTypeAnnotator()
()}
DefaultForTypeAnnotator
traverses types deeply.
This class takes care of two of the attributes of DefaultFor
; the others are handled
in QualifierDefaults
.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.checkerframework.framework.type.visitor.AnnotatedTypeScanner
AnnotatedTypeScanner.Reduce<R>
-
Field Summary
Fields inherited from class org.checkerframework.framework.type.typeannotator.TypeAnnotator
atypeFactory
Fields inherited from class org.checkerframework.framework.type.visitor.AnnotatedTypeScanner
defaultResult, reduceFunction, visitedNodes
-
Constructor Summary
ConstructorDescriptionDefaultForTypeAnnotator
(AnnotatedTypeFactory typeFactory) Creates aDefaultForTypeAnnotator
from the given checker, using that checker to determine the annotations that are in the type hierarchy. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAtmClass
(Class<? extends AnnotatedTypeMirror> typeClass, AnnotationMirror theQual) Add default qualifier,theQual
, for the givenAnnotatedTypeMirror
class.Adds standard rules.void
addTypeKind
(TypeKind typeKind, AnnotationMirror theQual) Add default qualifier,theQual
, for the given TypeKind.void
addTypes
(Class<?> clazz, AnnotationMirror theQual) Add default qualifier,theQual
, for the given type.void
defaultTypeFromName
(AnnotatedTypeMirror type, String name) Apply defaults based on a variable name to a type.protected Void
scan
(AnnotatedTypeMirror type, Void p) Scantype
by callingtype.accept(this, p)
; this method may be overridden by subclasses.Visits an executable type.Methods inherited from class org.checkerframework.framework.type.visitor.AnnotatedTypeScanner
reduce, reset, scan, scanAndReduce, scanAndReduce, visit, visit, visitArray, visitDeclared, visitIntersection, visitNoType, visitNull, visitPrimitive, visitTypeVariable, visitUnion, visitWildcard
-
Constructor Details
-
DefaultForTypeAnnotator
Creates aDefaultForTypeAnnotator
from the given checker, using that checker to determine the annotations that are in the type hierarchy.
-
-
Method Details
-
addTypeKind
Add default qualifier,theQual
, for the given TypeKind. -
addAtmClass
Add default qualifier,theQual
, for the givenAnnotatedTypeMirror
class. -
addTypes
Add default qualifier,theQual
, for the given type. -
scan
Description copied from class:AnnotatedTypeScanner
Scantype
by callingtype.accept(this, p)
; this method may be overridden by subclasses.- Overrides:
scan
in classAnnotatedTypeScanner<Void,
Void> - Parameters:
type
- type to scanp
- the parameter to use- Returns:
- the result of visiting
type
-
addStandardDefaults
Adds standard rules. Currently, sets Void to bottom if no other qualifier is set for Void. Also, seeLiteralTreeAnnotator.addStandardLiteralQualifiers()
.- Returns:
- this
-
defaultTypeFromName
Apply defaults based on a variable name to a type.- Parameters:
type
- a type to apply defaults toname
- the name of the variable that has typetype
, or the name of the method whose return type istype
-
visitExecutable
Description copied from class:TypeAnnotator
Visits an executable type.If this method adds annotations to the type of method parameters, then
GenericAnnotatedTypeFactory.addComputedTypeAnnotations(Element, AnnotatedTypeMirror)
should be overridden and the same annotations added to the type of elements with kindElementKind.PARAMETER
. Likewise for return types.- Specified by:
visitExecutable
in interfaceAnnotatedTypeVisitor<Void,
Void> - Overrides:
visitExecutable
in classTypeAnnotator
- Parameters:
type
- the type to visitaVoid
- a visitor-specified parameter- Returns:
- a visitor-specified result
-