Class DefaultQualifierForUseTypeAnnotator
- 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.DefaultQualifierForUseTypeAnnotator
-
- All Implemented Interfaces:
AnnotatedTypeVisitor<java.lang.Void,java.lang.Void>
public class DefaultQualifierForUseTypeAnnotator extends TypeAnnotator
Implements support forDefaultQualifierForUse
andNoDefaultQualifierForUse
. Adds default annotations on types that have no annotation.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.checkerframework.framework.type.visitor.AnnotatedTypeScanner
AnnotatedTypeScanner.Reduce<R>
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<javax.lang.model.element.Element,AnnotationMirrorSet>
elementToDefaults
Cache of elements to the set of annotations that should be applied to unannotated uses of the element.-
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 DefaultQualifierForUseTypeAnnotator(AnnotatedTypeFactory typeFactory)
Creates an DefaultQualifierForUseTypeAnnotator fortypeFactory
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearCache()
Clears all caches.protected AnnotationMirrorSet
getDefaultAnnosForUses(javax.lang.model.element.Element element)
Returns the set of qualifiers that should be applied to unannotated uses of the given elementprotected AnnotationMirrorSet
getDefaultQualifierForUses(javax.lang.model.element.Element element)
Return the default qualifiers for uses ofelement
as specified by aDefaultQualifierForUse
annotation.protected AnnotationMirrorSet
getExplicitAnnos(javax.lang.model.element.Element element)
Return the annotations explicitly written on the element.protected AnnotationMirrorSet
getHierarchiesNoDefault(javax.lang.model.element.Element element)
Returns top annotations in hierarchies for which no default for use qualifier should be added.protected AnnotationMirrorSet
supportedAnnosFromAnnotationMirror(java.util.List<@CanonicalName javax.lang.model.element.Name> annoClassNames)
Returns the set of qualifiers supported by this type system from the value element ofannotationMirror
.java.lang.Void
visitDeclared(AnnotatedTypeMirror.AnnotatedDeclaredType type, java.lang.Void aVoid)
Visits a declared type.-
Methods inherited from class org.checkerframework.framework.type.typeannotator.TypeAnnotator
visitExecutable
-
Methods inherited from class org.checkerframework.framework.type.visitor.AnnotatedTypeScanner
reduce, reset, scan, scan, scanAndReduce, scanAndReduce, visit, visit, visitArray, visitIntersection, visitNoType, visitNull, visitPrimitive, visitTypeVariable, visitUnion, visitWildcard
-
-
-
-
Field Detail
-
elementToDefaults
protected final java.util.Map<javax.lang.model.element.Element,AnnotationMirrorSet> elementToDefaults
Cache of elements to the set of annotations that should be applied to unannotated uses of the element.
-
-
Constructor Detail
-
DefaultQualifierForUseTypeAnnotator
public DefaultQualifierForUseTypeAnnotator(AnnotatedTypeFactory typeFactory)
Creates an DefaultQualifierForUseTypeAnnotator fortypeFactory
.- Parameters:
typeFactory
- the type factory
-
-
Method Detail
-
visitDeclared
public java.lang.Void visitDeclared(AnnotatedTypeMirror.AnnotatedDeclaredType type, java.lang.Void aVoid)
Description copied from interface:AnnotatedTypeVisitor
Visits a declared type.- Specified by:
visitDeclared
in interfaceAnnotatedTypeVisitor<java.lang.Void,java.lang.Void>
- Overrides:
visitDeclared
in classAnnotatedTypeScanner<java.lang.Void,java.lang.Void>
- Parameters:
type
- the type to visitaVoid
- a visitor-specified parameter- Returns:
- a visitor-specified result
-
clearCache
public void clearCache()
Clears all caches.
-
getDefaultAnnosForUses
protected AnnotationMirrorSet getDefaultAnnosForUses(javax.lang.model.element.Element element)
Returns the set of qualifiers that should be applied to unannotated uses of the given element- Parameters:
element
- the element for which to determine default qualifiers- Returns:
- the set of qualifiers that should be applied to unannotated uses of
element
-
getExplicitAnnos
protected AnnotationMirrorSet getExplicitAnnos(javax.lang.model.element.Element element)
Return the annotations explicitly written on the element.- Parameters:
element
- an element- Returns:
- the annotations explicitly written on the element
-
getDefaultQualifierForUses
protected AnnotationMirrorSet getDefaultQualifierForUses(javax.lang.model.element.Element element)
Return the default qualifiers for uses ofelement
as specified by aDefaultQualifierForUse
annotation.Subclasses may override to use an annotation other than
DefaultQualifierForUse
.- Parameters:
element
- an element- Returns:
- the default qualifiers for uses of
element
-
getHierarchiesNoDefault
protected AnnotationMirrorSet getHierarchiesNoDefault(javax.lang.model.element.Element element)
Returns top annotations in hierarchies for which no default for use qualifier should be added.- Parameters:
element
- an element- Returns:
- top annotations in hierarchies for which no default for use qualifier should be added
-
supportedAnnosFromAnnotationMirror
protected final AnnotationMirrorSet supportedAnnosFromAnnotationMirror(java.util.List<@CanonicalName javax.lang.model.element.Name> annoClassNames)
Returns the set of qualifiers supported by this type system from the value element ofannotationMirror
.- Parameters:
annoClassNames
- a list of annotation class names- Returns:
- the set of qualifiers supported by this type system from the value element of
annotationMirror
-
-