public abstract class DefaultQualifiedTypeFactory<Q> extends Object implements QualifiedTypeFactory<Q>
QualifiedTypeFactory. Most type systems
should extend this class (or a subclass) instead of implementing QualifiedTypeFactory directly.
This implementation decomposes the problem of type checking using several
helper classes:
AnnotationConverter: Converts annotations written in the source
code into type qualifiers for use in type checking. TypeAnnotator: A visitor for
ExtendedTypeMirrors that
adds a qualifier to each component of the type, producing a QualifiedTypeMirror. TreeAnnotator: A visitor for Trees that computes the
qualified type of each AST node based on the qualified types of its
subnodes. QualifierHierarchy: Used to perform subtyping checks between
two type qualifiers (independent of any Java types). TypeHierarchy: Used to perform subtyping checks between two
QualifiedTypeMirrors. TypeAnnotator, TreeAnnotator, and TypeHierarchy. The type system must provide
implementations for AnnotationConverter and QualifierHierarchy.| Constructor and Description |
|---|
DefaultQualifiedTypeFactory(QualifierContext<Q> context) |
public DefaultQualifiedTypeFactory(QualifierContext<Q> context)
public final QualifiedTypeMirror<Q> getQualifiedType(Element element)
QualifiedTypeFactoryElement.getQualifiedType in interface QualifiedTypeFactory<Q>public final QualifiedTypeMirror<Q> getQualifiedType(Tree tree)
QualifiedTypeFactorygetQualifiedType in interface QualifiedTypeFactory<Q>public final QualifiedTypeMirror<Q> getQualifiedTypeFromTypeTree(Tree typeTree)
QualifiedTypeFactoryTree form.getQualifiedTypeFromTypeTree in interface QualifiedTypeFactory<Q>public final QualifiedTypeParameterBounds<Q> getQualifiedTypeParameterBounds(ExtendedParameterDeclaration etm)
QualifiedTypeFactoryElement.getQualifiedTypeParameterBounds in interface QualifiedTypeFactory<Q>protected QualifiedTypeParameterBounds<Q> computeQualifiedTypeParameterBounds(ExtendedParameterDeclaration etm)
TypeAnnotator.protected TreeAnnotator<Q> createTreeAnnotator()
TreeAnnotator to be used by this type factory.
Checkers that need custom TreeAnnotator behavior should
override this method to return an instance of their custom TreeAnnotator subclass.protected TypeAnnotator<Q> createTypeAnnotator()
TypeAnnotator to be used by this type factory.
Checkers that need custom TypeAnnotator behavior should
override this method to return an instance of their custom TypeAnnotator subclass.public final QualifiedTypes<Q> getQualifiedTypes()
QualifiedTypeFactoryQualifiedTypes helper object used with this type
system.getQualifiedTypes in interface QualifiedTypeFactory<Q>protected QualifiedTypes<Q> createQualifiedTypes()
public QualifierHierarchy<Q> getQualifierHierarchy()
QualifiedTypeFactoryQualifierHierarchy used with this type system.getQualifierHierarchy in interface QualifiedTypeFactory<Q>protected abstract QualifierHierarchy<Q> createQualifierHierarchy()
QualifierHierarchy for the current type system.
Every checker must override this method to return an appropriate QualifierHierarchy subclass for that checker.public TypeHierarchy<Q> getTypeHierarchy()
QualifiedTypeFactoryTypeHierarchy used with this type system.getTypeHierarchy in interface QualifiedTypeFactory<Q>protected TypeHierarchy<Q> createTypeHierarchy(QualifierHierarchy<Q> qualifierHierarchy)
TypeHierarchy for the current type system. The
default implementation constructs a DefaultTypeHierarchy.qualifierHierarchy - a reference to the QualifierHierarchy used by this type systempublic AnnotationConverter<Q> getAnnotationConverter()
AnnotationConverter for the current type system.protected abstract AnnotationConverter<Q> createAnnotationConverter()
AnnotationConverter for the current type system.
Every checker must override this method to return an appropriate AnnotationConverter subclass for that checker.public List<QualifiedTypeMirror<Q>> postDirectSuperTypes(QualifiedTypeMirror<Q> subtype, List<? extends QualifiedTypeMirror<Q>> supertypes)
QualifiedTypeFactorydirectSuperTypes.postDirectSuperTypes in interface QualifiedTypeFactory<Q>subtype - the target of the directSuperTypes callsupertypes - the supertypes produced by the default
directSuperTypes implementationsupertypes after applying checker-specific
adjustmentspublic QualifiedTypeMirror<Q> postAsMemberOf(QualifiedTypeMirror<Q> memberType, QualifiedTypeMirror<Q> receiverType, Element memberElement)
QualifiedTypeFactoryasMemberOf.postAsMemberOf in interface QualifiedTypeFactory<Q>memberType - the type of the element being accessed, according to the default
asMemberOf implementationreceiverType - the type of the object instance whose element is being accessedmemberElement - the element being accessedmemberType after applying checker-specific
adjustmentspublic Pair<QualifiedTypeMirror.QualifiedExecutableType<Q>,List<QualifiedTypeMirror<Q>>> methodFromUse(MethodInvocationTree tree)
QualifiedTypeFactorymethodFromUse in interface QualifiedTypeFactory<Q>tree - the AST node for the method callpublic Pair<QualifiedTypeMirror.QualifiedExecutableType<Q>,List<QualifiedTypeMirror<Q>>> methodFromUse(ExpressionTree tree, ExecutableElement methodElt, QualifiedTypeMirror<Q> receiverType)
methodFromUse in interface QualifiedTypeFactory<Q>QualifiedTypeFactory.methodFromUse(MethodInvocationTree)public Pair<QualifiedTypeMirror.QualifiedExecutableType<Q>,List<QualifiedTypeMirror<Q>>> constructorFromUse(NewClassTree tree)
QualifiedTypeFactoryconstructorFromUse in interface QualifiedTypeFactory<Q>tree - the AST node for the constructor callpublic QualAnalysis<Q> createFlowAnalysis(List<Pair<VariableElement,QualValue<Q>>> fieldValues)
QualifiedTypeFactoryAnalysis to configure dataflow.createFlowAnalysis in interface QualifiedTypeFactory<Q>fieldValues - The initial field valuesQualAnalysis to usepublic QualifierContext<Q> getContext()
public QualifiedTypeMirror<Q> getReceiverType(ExpressionTree expression)
QualifiedTypeFactorygetReceiverType in interface QualifiedTypeFactory<Q>expression - The expression for which to determine the receiver typepublic ExtendedTypeMirror getDecoratedElement(Element element)
QualifiedTypeFactoryExtendedTypeMirror for an Element that has all the Annotations
that were located on the element in source code or in stub files.getDecoratedElement in interface QualifiedTypeFactory<Q>element - The ElementExtendedTypeMirrorpublic TypeVariableSubstitutor<Q> createTypeVariableSubstitutor()
createTypeVariableSubstitutor in interface QualifiedTypeFactory<Q>public Set<AnnotationMirror> getDeclAnnotations(Element elt)
getDeclAnnotations in interface QualifiedTypeFactory<Q>