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
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.


Nested Class Summary
Modifier and Type Class and Description
 
Nested classes/interfaces inherited from class checkers.types.AnnotatedTypeFactory
AnnotatedTypeFactory.InheritedFromClassAnnotator
 
Field Summary
Modifier and Type Field and Description
 
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, fromTreeCache, qualHierarchy, root, trees, types, uid, visitorState
 
Constructor Summary
Constructor and Description
InterningAnnotatedTypeFactory(InterningChecker checker, CompilationUnitTree root)
          Creates a new InterningAnnotatedTypeFactory that operates on a particular AST.
 
Method Summary
Modifier and Type Method and Description
protected  void annotateImplicit(Element element, AnnotatedTypeMirror type)
          Adds implicit annotations to a type obtained from a Element.
protected  void annotateInheritedFromClass(AnnotatedTypeMirror type)
          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.
protected  TreeAnnotator createTreeAnnotator(InterningChecker checker)
          Returns a TreeAnnotator that adds annotations to a type based on the contents of a tree.
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, createFlow, createFlowQualifiers, methodFromUse, postDirectSuperTypes
 
Methods inherited from class checkers.types.AnnotatedTypeFactory
addAliasedAnnotation, 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, postInit, toAnnotatedType, toString, unify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, 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

createTreeAnnotator

protected TreeAnnotator createTreeAnnotator(InterningChecker checker)
Description copied from class: BasicAnnotatedTypeFactory
Returns a TreeAnnotator that adds annotations to a type based on the contents of a tree. Subclasses may override this method to specify more appriopriate TreeAnnotator

Overrides:
createTreeAnnotator in class BasicAnnotatedTypeFactory<InterningChecker>
Returns:
a tree annotator

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

annotateImplicit

protected void annotateImplicit(Element element,
                                AnnotatedTypeMirror type)
Description copied from class: AnnotatedTypeFactory
Adds implicit annotations to a type obtained from a Element. By default, this method does nothing. Subclasses should use this method to implement implicit annotations specific to their type systems.

Overrides:
annotateImplicit in class BasicAnnotatedTypeFactory<InterningChecker>
Parameters:
element - an element
type - the type obtained from elt

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
                                          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