Class DefaultForTypeAnnotator
- java.lang.Object
-
- org.checkerframework.framework.type.visitor.AnnotatedTypeScanner<java.lang.Void,java.lang.Void>
-
- org.checkerframework.framework.type.typeannotator.TypeAnnotator
-
- org.checkerframework.framework.type.typeannotator.DefaultForTypeAnnotator
-
- All Implemented Interfaces:
AnnotatedTypeVisitor<java.lang.Void,java.lang.Void>
public class DefaultForTypeAnnotator extends TypeAnnotator
Adds annotations to a type based on the use of a type. This class applies annotations specified byDefaultFor
; it is designed to be used in aListTypeAnnotator
constructed inGenericAnnotatedTypeFactory.createTypeAnnotator()
()}DefaultForTypeAnnotator
traverses types deeply.This class takes care of two of the attributes of
DefaultFor
; the others are handled inQualifierDefaults
.- See Also:
ListTypeAnnotator
-
-
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
Constructors Constructor Description DefaultForTypeAnnotator(AnnotatedTypeFactory typeFactory)
Creates aDefaultForTypeAnnotator
from the given checker, using that checker to determine the annotations that are in the type hierarchy.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAtmClass(java.lang.Class<? extends AnnotatedTypeMirror> typeClass, javax.lang.model.element.AnnotationMirror theQual)
Add default qualifier,theQual
, for the givenAnnotatedTypeMirror
class.DefaultForTypeAnnotator
addStandardDefaults()
Adds standard rules.void
addTypeKind(javax.lang.model.type.TypeKind typeKind, javax.lang.model.element.AnnotationMirror theQual)
Add default qualifier,theQual
, for the given TypeKind.void
addTypes(java.lang.Class<?> clazz, javax.lang.model.element.AnnotationMirror theQual)
Add default qualifier,theQual
, for the given type.void
defaultTypeFromName(AnnotatedTypeMirror type, java.lang.String name)
Apply defaults based on a variable name to a type.protected java.lang.Void
scan(AnnotatedTypeMirror type, java.lang.Void p)
Scantype
by callingtype.accept(this, p)
; this method may be overridden by subclasses.java.lang.Void
visitExecutable(AnnotatedTypeMirror.AnnotatedExecutableType type, java.lang.Void aVoid)
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 Detail
-
DefaultForTypeAnnotator
public DefaultForTypeAnnotator(AnnotatedTypeFactory typeFactory)
Creates aDefaultForTypeAnnotator
from the given checker, using that checker to determine the annotations that are in the type hierarchy.
-
-
Method Detail
-
addTypeKind
public void addTypeKind(javax.lang.model.type.TypeKind typeKind, javax.lang.model.element.AnnotationMirror theQual)
Add default qualifier,theQual
, for the given TypeKind.
-
addAtmClass
public void addAtmClass(java.lang.Class<? extends AnnotatedTypeMirror> typeClass, javax.lang.model.element.AnnotationMirror theQual)
Add default qualifier,theQual
, for the givenAnnotatedTypeMirror
class.
-
addTypes
public void addTypes(java.lang.Class<?> clazz, javax.lang.model.element.AnnotationMirror theQual)
Add default qualifier,theQual
, for the given type.
-
scan
protected java.lang.Void scan(AnnotatedTypeMirror type, java.lang.Void p)
Description copied from class:AnnotatedTypeScanner
Scantype
by callingtype.accept(this, p)
; this method may be overridden by subclasses.- Overrides:
scan
in classAnnotatedTypeScanner<java.lang.Void,java.lang.Void>
- Parameters:
type
- type to scanp
- the parameter to use- Returns:
- the result of visiting
type
-
addStandardDefaults
public DefaultForTypeAnnotator addStandardDefaults()
Adds standard rules. Currently, sets Void to bottom if no other qualifier is set for Void. Also, seeLiteralTreeAnnotator.addStandardLiteralQualifiers()
.- Returns:
- this
-
defaultTypeFromName
public void defaultTypeFromName(AnnotatedTypeMirror type, java.lang.String name)
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
public java.lang.Void visitExecutable(AnnotatedTypeMirror.AnnotatedExecutableType type, java.lang.Void aVoid)
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<java.lang.Void,java.lang.Void>
- Overrides:
visitExecutable
in classTypeAnnotator
- Parameters:
type
- the type to visitaVoid
- a visitor-specified parameter- Returns:
- a visitor-specified result
-
-