Class QualifierDefaults.DefaultApplierElement
java.lang.Object
org.checkerframework.framework.util.defaults.QualifierDefaults.DefaultApplierElement
- Enclosing class:
QualifierDefaults
A default applier element.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AnnotatedTypeFactoryThe annotated type factory.protected final booleanWhether the element came from a tree.protected TypeUseLocationLocation to which to apply the default.protected final QualifierHierarchyThe qualifier hierarchy.protected final ElementThe scope of the default.protected final AnnotatedTypeMirrorThe type to which to apply the default. -
Constructor Summary
ConstructorsConstructorDescriptionDefaultApplierElement(AnnotatedTypeFactory atypeFactory, Element scope, AnnotatedTypeMirror type, boolean fromTree) Create an instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddAnnotation(AnnotatedTypeMirror type, AnnotationMirror qual) Add the qualifier to the type if it does not already have an annotation in the same hierarchy as qual.voidapplyDefaults(List<Default> defaults) Apply all ofdefaults(in precedence order) to the type in a single traversal, rather than scanning the whole type once per default.protected booleanReturns true if the given qualifier should be applied to the given type.
-
Field Details
-
atypeFactory
The annotated type factory. -
qualHierarchy
The qualifier hierarchy. -
scope
The scope of the default. -
type
The type to which to apply the default. -
fromTree
protected final boolean fromTreeWhether the element came from a tree. -
location
Location to which to apply the default. (Should only be set by the applyDefault method.)
-
-
Constructor Details
-
DefaultApplierElement
public DefaultApplierElement(AnnotatedTypeFactory atypeFactory, Element scope, AnnotatedTypeMirror type, boolean fromTree) Create an instance.- Parameters:
atypeFactory- the type factoryscope- the scope for the defaultstype- the type to defaultfromTree- whether the element came from a tree
-
-
Method Details
-
applyDefaults
Apply all ofdefaults(in precedence order) to the type in a single traversal, rather than scanning the whole type once per default.addMissingAnnotationonly adds an annotation when the hierarchy is unannotated, so a single ordered pass reproduces the precedence of the old per-default scans.- Parameters:
defaults- the defaults to apply, in precedence order
-
shouldBeAnnotated
Returns true if the given qualifier should be applied to the given type. Currently we do not apply defaults to void types, none types, wildcards, type variables, packages, and modules.- Parameters:
type- type to which qual would be applied- Returns:
- true if this application should proceed
-
addAnnotation
Add the qualifier to the type if it does not already have an annotation in the same hierarchy as qual.- Parameters:
type- type to add qualqual- annotation to add
-