checkers.types
Class BasicAnnotatedTypeFactory<Checker extends BaseTypeChecker>

java.lang.Object
  extended by checkers.types.AnnotatedTypeFactory
      extended by checkers.types.BasicAnnotatedTypeFactory<Checker>
Direct Known Subclasses:
IGJAnnotatedTypeFactory, InterningAnnotatedTypeFactory

public class BasicAnnotatedTypeFactory<Checker extends BaseTypeChecker>
extends AnnotatedTypeFactory

A factory that extends AnnotatedTypeFactory to optionally use flow-sensitive qualifier inference, qualifier polymorphism, implicit annotations via ImplicitFor, and user-specified defaults via DefaultQualifier

See Also:
Flow

Field Summary
protected  QualifierDefaults defaults
          to handle defaults specified by the user
protected  Flow flow
          Flow sensitive instance
protected static boolean FLOW_BY_DEFAULT
          should use flow by default
protected  QualifierPolymorphism poly
          to handle any polymorphic types
protected  TreeAnnotator treeAnnotator
          to annotate types based on the given un-annotated types
protected  TypeAnnotator typeAnnotator
          to annotate types based on the given tree
protected  boolean useFlow
          Should use flow analysis?
 
Fields inherited from class checkers.types.AnnotatedTypeFactory
annotations, atypes, elements, eltsToArrays, env, JSR308_ELTS_ARRAY_CONVENTION, qualHierarchy, root, trees, types, visitorState
 
Constructor Summary
BasicAnnotatedTypeFactory(Checker checker, CompilationUnitTree root)
          Creates a type factory for checking the given compilation unit with respect to the given annotation.
BasicAnnotatedTypeFactory(Checker checker, CompilationUnitTree root, boolean useFlow)
          Creates a type factory for checking the given compilation unit with respect to the given annotation.
 
Method Summary
protected  void annotateImplicit(Element elt, AnnotatedTypeMirror type)
          Adds implicit annotations to a type obtained from a Element.
protected  void annotateImplicit(Tree tree, AnnotatedTypeMirror type)
          Adds implicit annotations to a type obtained from a Tree.
protected  TreeAnnotator createTreeAnnotator(Checker checker)
          Returns a TreeAnnotator that adds annotations to a type based on the contents of a tree.
protected  TypeAnnotator createTypeAnnotator(Checker checker)
          Returns a TypeAnnotator that adds annotations to a type based on the content of the type itself.
 AnnotatedTypeMirror.AnnotatedExecutableType methodFromUse(MethodInvocationTree tree)
          Determines the type of the invoked method based on the passed method invocation tree.
 
Methods inherited from class checkers.types.AnnotatedTypeFactory
annotateInheritedFromClass, constructorFromUse, createLRUCache, declarationFromElement, fromClass, fromElement, fromElement, fromElement, fromExpression, fromMember, fromTypeTree, fromTypeTreeInternal, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedTypeFromTypeTree, getBoxedType, getCurrentClassType, getCurrentMethodReceiver, getPath, getReceiver, getSelfType, getUnboxedType, getVisitorState, postAsMemberOf, postDirectSuperTypes, unify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FLOW_BY_DEFAULT

protected static boolean FLOW_BY_DEFAULT
should use flow by default


typeAnnotator

protected final TypeAnnotator typeAnnotator
to annotate types based on the given tree


treeAnnotator

protected final TreeAnnotator treeAnnotator
to annotate types based on the given un-annotated types


poly

protected final QualifierPolymorphism poly
to handle any polymorphic types


defaults

protected final QualifierDefaults defaults
to handle defaults specified by the user


useFlow

protected boolean useFlow
Should use flow analysis?


flow

protected final Flow flow
Flow sensitive instance

Constructor Detail

BasicAnnotatedTypeFactory

public BasicAnnotatedTypeFactory(Checker checker,
                                 CompilationUnitTree root,
                                 boolean useFlow)
Creates a type factory for checking the given compilation unit with respect to the given annotation.

Parameters:
checker - the checker to which this type factory belongs
root - the compilation unit to scan
useFlow - whether flow analysis should be performed

BasicAnnotatedTypeFactory

public BasicAnnotatedTypeFactory(Checker checker,
                                 CompilationUnitTree root)
Creates a type factory for checking the given compilation unit with respect to the given annotation.

Parameters:
checker - the checker to which this type factory belongs
root - the compilation unit to scan
Method Detail

createTreeAnnotator

protected TreeAnnotator createTreeAnnotator(Checker checker)
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

Returns:
a tree annotator

createTypeAnnotator

protected TypeAnnotator createTypeAnnotator(Checker checker)
Returns a TypeAnnotator that adds annotations to a type based on the content of the type itself.

Returns:
a type annotator

annotateImplicit

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

Overrides:
annotateImplicit in class AnnotatedTypeFactory
Parameters:
tree - an AST node
type - the type obtained from tree

annotateImplicit

protected void annotateImplicit(Element elt,
                                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 AnnotatedTypeFactory
Parameters:
elt - an element
type - the type obtained from elt

methodFromUse

public AnnotatedTypeMirror.AnnotatedExecutableType methodFromUse(MethodInvocationTree tree)
Description copied from class: AnnotatedTypeFactory
Determines the type of the invoked method based on the passed method invocation tree. The returned method type has all type variables resolved, whether based on receiver type, passed type parameters if any, and method invocation parameter. Subclasses may override this method to customize inference of types or qualifiers based on method invocation parameters. As an implementation detail, this method depends on AnnotatedTypes.asMemberOf(AnnotatedTypeMirror, Element), and customization based on receiver type should be in accordance to its specification.

Overrides:
methodFromUse in class AnnotatedTypeFactory
Parameters:
tree - the method invocation tree
Returns:
the method type being invoked with tree