checkers.interning
Class InterningAnnotatedTypeFactory

java.lang.Object
  extended by checkers.types.AnnotatedTypeFactory
      extended by checkers.types.BasicAnnotatedTypeFactory<InterningChecker>
          extended by 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: 1. is a String literal 2. is a class literal 3. has an enum type 4. has a primitive type 5. has the type java.lang.Class 6. is a call to the method String.intern(). The method is the only interning method in the JDK. This class hard-codes handling of it, so there is no need for an annotated JDK. This factory extends BasicAnnotatedTypeFactory and inherits its functionalities: flow-sensitive qualifier inference, qualifier polymorphism (of PolyInterned), implicit annotations via ImplicitFor (to handle cases 1, 4), and user-specified defaults via DefaultQualifier.


Field Summary
 
Fields inherited from class checkers.types.BasicAnnotatedTypeFactory
defaults, flow, FLOW_BY_DEFAULT, poly, treeAnnotator, typeAnnotator, useFlow
 
Fields inherited from class checkers.types.AnnotatedTypeFactory
annotations, atypes, elements, env, qualHierarchy, root, trees, types, visitorState
 
Constructor Summary
InterningAnnotatedTypeFactory(InterningChecker checker, CompilationUnitTree root)
          Creates a new InterningAnnotatedTypeFactory that operates on a particular AST.
 
Method Summary
protected  TypeAnnotator createTypeAnnotator(InterningChecker checker)
          Returns a TypeAnnotator that adds annotations to a type based on the content of the type itself.
 AnnotatedTypeMirror.AnnotatedPrimitiveType getUnboxedType(AnnotatedTypeMirror.AnnotatedDeclaredType type)
          returns the annotated primitive type of the given declared type if it is a boxed declared type.
 
Methods inherited from class checkers.types.BasicAnnotatedTypeFactory
annotateImplicit, annotateImplicit, createFlow, createTreeAnnotator, methodFromUse, postDirectSuperTypes
 
Methods inherited from class checkers.types.AnnotatedTypeFactory
annotateInheritedFromClass, constructorFromUse, createLRUCache, declarationFromElement, fromClass, fromElement, fromElement, fromElement, fromExpression, fromMember, fromTypeTree, fromTypeTree, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedTypeFromTypeTree, getBoxedType, getCurrentClassType, getCurrentMethodReceiver, getEnclosingType, getImplicitReceiverType, getPath, getQualifierHierarchy, getReceiver, getSelfType, getVisitorState, isMostEnclosingThisDeref, postAsMemberOf, unify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InterningAnnotatedTypeFactory

public InterningAnnotatedTypeFactory(InterningChecker checker,
                                     CompilationUnitTree root)
Creates a new InterningAnnotatedTypeFactory that operates on a particular AST.

Parameters:
checker - the checker to use
root - the AST on which this type factory operates
Method Detail

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