checkers.interning
Class InterningAnnotatedTypeFactory
java.lang.Object
checkers.types.AnnotatedTypeFactory
checkers.types.BasicAnnotatedTypeFactory<InterningChecker>
checkers.interning.InterningAnnotatedTypeFactory
public class InterningAnnotatedTypeFactory
extends BasicAnnotatedTypeFactory<InterningChecker>
An AnnotatedTypeFactory
that accounts for the properties of the
Interned type system. This type factory will add the Interned
annotation to a type if the input:
- is a String literal
- is a class literal
- has an enum type
- has a primitive type
- has the type java.lang.Class
This factory extends BasicAnnotatedTypeFactory
and inherits its
functionality, including: flow-sensitive qualifier inference, qualifier
polymorphism (of PolyInterned
), implicit annotations via
ImplicitFor
on Interned
(to handle cases 1, 2, 4), and
user-specified defaults via DefaultQualifier
.
Case 5 is handled by the stub library.
Methods inherited from class checkers.types.AnnotatedTypeFactory |
aliasedAnnotation, canHaveAnnotatedTypeParameters, constructorFromUse, createLRUCache, declarationFromElement, fromClass, fromElement, fromElement, fromElement, fromExpression, fromMember, fromNewClass, fromTypeTree, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedTypeFromTypeTree, getBoxedType, getCurrentClassType, getCurrentMethodReceiver, getEnclosingType, getImplicitReceiverType, getPath, getQualifierHierarchy, getReceiver, getSelfType, getVisitorState, isMostEnclosingThisDeref, isWithinConstructor, postAsMemberOf, unify |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
InterningAnnotatedTypeFactory
public InterningAnnotatedTypeFactory(InterningChecker checker,
CompilationUnitTree root)
- Creates a new
InterningAnnotatedTypeFactory
that operates on a
particular AST.
- Parameters:
checker
- the checker to useroot
- the AST on which this type factory operates
createTypeAnnotator
protected TypeAnnotator createTypeAnnotator(InterningChecker checker)
- Description copied from class:
BasicAnnotatedTypeFactory
- Returns a
TypeAnnotator
that adds annotations to a type based
on the content of the type itself.
- Overrides:
createTypeAnnotator
in class BasicAnnotatedTypeFactory<InterningChecker>
- Returns:
- a type annotator
getUnboxedType
public AnnotatedTypeMirror.AnnotatedPrimitiveType getUnboxedType(AnnotatedTypeMirror.AnnotatedDeclaredType type)
- Description copied from class:
AnnotatedTypeFactory
- returns the annotated primitive type of the given declared type
if it is a boxed declared type. Otherwise, it throws
IllegalArgumentException exception.
The returned type would have the annotations on the given type and
nothing else.
- Overrides:
getUnboxedType
in class AnnotatedTypeFactory
- Parameters:
type
- the declared type
- Returns:
- the unboxed primitive type
annotateInheritedFromClass
protected void annotateInheritedFromClass(@Mutable
@Mutable AnnotatedTypeMirror type)
- Description copied from class:
AnnotatedTypeFactory
- Adds annotations to the type based on the annotations from its class
type if and only if no annotations are already present on the type.
- Overrides:
annotateInheritedFromClass
in class AnnotatedTypeFactory
- Parameters:
type
- the type for which class annotations will be inherited if
there are no annotations already present