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, ImmutabilityAnnotatedTypeFactory, InterningAnnotatedTypeFactory, LinearAnnotatedTypeFactory, LockAnnotatedTypeFactory, OwnershipAnnotatedTypeFactory, PropertyKeyAnnotatedTypeFactory, RegexAnnotatedTypeFactory, TaintingAnnotatedTypeFactory

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

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
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, env, fromTreeCache, qualHierarchy, root, trees, types, visitorState
 
Constructor Summary
Constructor and Description
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
Modifier and Type Method and Description
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  Flow createFlow(Checker checker, CompilationUnitTree root, Set<AnnotationMirror> flowQuals)
          Returns a Flow instance that performs flow sensitive analysis to infer qualifiers on unqualified types.
protected  Set<AnnotationMirror> createFlowQualifiers(Checker checker)
          Returns the set of annotations to be inferred in flow analysis
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.
protected  void postDirectSuperTypes(AnnotatedTypeMirror type, List<? extends AnnotatedTypeMirror> supertypes)
          A callback method for the AnnotatedTypeFactory subtypes to customize directSuperTypes().
 
Methods inherited from class checkers.types.AnnotatedTypeFactory
aliasedAnnotation, annotateInheritedFromClass, 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, getUnboxedType, getVisitorState, isMostEnclosingThisDeref, isWithinConstructor, postAsMemberOf, 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

createFlow

protected Flow createFlow(Checker checker,
                          CompilationUnitTree root,
                          Set<AnnotationMirror> flowQuals)
Returns a Flow instance that performs flow sensitive analysis to infer qualifiers on unqualified types.

Parameters:
checker - the checker
root - the compilation unit associated with this factory
flowQuals - the qualifiers to infer
Returns:
the flow analysis class

postDirectSuperTypes

protected void postDirectSuperTypes(AnnotatedTypeMirror type,
                                    List<? extends AnnotatedTypeMirror> supertypes)
Description copied from class: AnnotatedTypeFactory
A callback method for the AnnotatedTypeFactory subtypes to customize directSuperTypes(). Overriding methods should merely change the annotations on the supertypes, without adding or removing new types The default provided implementation adds type annotations to supertypes. This allows the type and its supertypes to have the qualifiers, e.g. the supertypes of an Immutable type are also Immutable.

Overrides:
postDirectSuperTypes in class AnnotatedTypeFactory
Parameters:
type - the type whose supertypes are desired
supertypes - the supertypes as specified by the base AnnotatedTypeFactory

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

createFlowQualifiers

protected Set<AnnotationMirror> createFlowQualifiers(Checker checker)
Returns the set of annotations to be inferred in flow analysis