public class UnitsAnnotatedTypeFactory extends BaseAnnotatedTypeFactory
| Modifier and Type | Class and Description |
|---|---|
protected class |
UnitsAnnotatedTypeFactory.UnitsQualifierHierarchy |
GenericAnnotatedTypeFactory.ScanStateAnnotatedTypeFactory.InheritedFromClassAnnotator| Modifier and Type | Field and Description |
|---|---|
protected AnnotationMirror |
BOTTOM |
protected AnnotationMirror |
mixedUnits |
protected AnnotationMirror |
TOP |
analyses, cfgVisualizer, defaults, FLOW_BY_DEFAULT, flowResult, initializationStaticStore, initializationStore, methodInvocationStores, poly, regularExitStores, returnStatementStores, scannedClasses, treeAnnotator, typeAnnotatorchecker, elements, fromTreeCache, loader, processingEnv, qualHierarchy, reflectionResolver, root, shouldCache, trees, typeArgumentInference, typeFormatter, typeHierarchy, types, typeVarSubstitutor, uid, visitorState| Constructor and Description |
|---|
UnitsAnnotatedTypeFactory(BaseTypeChecker checker) |
| Modifier and Type | Method and Description |
|---|---|
AnnotationMirror |
aliasedAnnotation(AnnotationMirror anno)
Returns the canonical annotation for the passed annotation if it is
an alias of a canonical one in the framework.
|
protected AnnotatedTypeFormatter |
createAnnotatedTypeFormatter()
Creates the AnnotatedTypeFormatter used by this type factory and all AnnotatedTypeMirrors
it creates.
|
QualifierHierarchy |
createQualifierHierarchy(MultiGraphQualifierHierarchy.MultiGraphFactory factory)
Set the Bottom qualifier as the bottom of the hierarchy.
|
protected Set<Class<? extends Annotation>> |
createSupportedTypeQualifiers()
Returns an immutable set of annotation classes that are supported by a checker
|
TreeAnnotator |
createTreeAnnotator()
Returns a
TreeAnnotator that adds annotations to a type based
on the contents of a tree. |
protected Map<String,UnitsRelations> |
getUnitsRel() |
createFlowAnalysisaddCheckedCodeDefaults, addTypeNameImplicit, addUncheckedCodeDefaults, analyze, analyze, annotateImplicit, annotateImplicit, annotateImplicit, applyInferredAnnotations, checkAndPerformFlowAnalysis, constructorFromUse, createCFGVisualizer, createFlowTransferFunction, createQualifierDefaults, createQualifierPolymorphism, createTypeAnnotator, getAnnotatedTypeLhs, getAnnotatedTypeLhsNoTypeVarDefault, getCFGVisualizer, getEmptyStore, getFinalLocalValues, getInferredValueFor, getNodeForTree, getRegularExitStore, getResultingTypeOfConstructorMemberReference, getReturnStatementStores, getShouldDefaultTypeVarLocals, getSortedQualifierNames, getStoreAfter, getStoreBefore, getStoreBefore, getSupportedMonotonicTypeQualifiers, getTypeFactoryOfSubchecker, handleCFGViz, methodFromUse, performFlowAnalysis, postDirectSuperTypes, postInit, setRootadaptGetClassReturnTypeToReceiver, addAliasedAnnotation, addAliasedDeclAnnotation, addInheritedAnnotation, annotateInheritedFromClass, annotateInheritedFromClass, checkInvalidOptionsInferSignatures, createAnnotationFormatter, createQualifierHierarchy, createQualifierHierarchy, createQualifierHierarchyFactory, createTypeArgumentInference, createTypeHierarchy, createTypeVariableSubstitutor, declarationFromElement, fromElement, fromElement, fromElement, fromNewClass, getAnnotatedNullType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedTypeFromTypeTree, getAnnotationFormatter, getAnnotationMirror, getAnnotationWithMetaAnnotation, getBoxedType, getBundledTypeQualifiersWithoutPolyAll, getBundledTypeQualifiersWithPolyAll, getContext, getCurrentClassTree, getCurrentClassType, getCurrentMethodReceiver, getDeclAnnotation, getDeclAnnotationNoAliases, getDeclAnnotations, getDeclAnnotationWithMetaAnnotation, getElementUtils, getEnclosingMethod, getEnclosingType, getFnInterfaceFromTree, getFnInterfaceFromTree, getImplicitReceiverType, getMethodReturnType, getMethodReturnType, getPath, getProcessingEnv, getQualifierHierarchy, getReceiverType, getSelfType, getSupportedTypeQualifiers, getTreeUtils, getTypeArgumentInference, getTypeHierarchy, getTypeVarSubstitutor, getUnboxedType, getUninferredWildcardType, getVisitorState, getWholeProgramInference, initilizeReflectionResolution, isAnyEnclosingThisDeref, isFromByteCode, isFromStubFile, isMostEnclosingThisDeref, isSupportedQualifier, isWithinConstructor, methodFromUse, parseStubFiles, postAsMemberOf, postProcessClassTree, postTypeVarSubstitution, setPathHack, toAnnotatedType, toString, type, typeVariablesFromUse, widenToUpperBoundprotected final AnnotationMirror mixedUnits
protected final AnnotationMirror TOP
protected final AnnotationMirror BOTTOM
public UnitsAnnotatedTypeFactory(BaseTypeChecker checker)
protected AnnotatedTypeFormatter createAnnotatedTypeFormatter()
AnnotatedTypeFactorycreateAnnotatedTypeFormatter in class AnnotatedTypeFactorypublic AnnotationMirror aliasedAnnotation(AnnotationMirror anno)
AnnotatedTypeFactoryReturns an aliased type of the current one
aliasedAnnotation in class AnnotatedTypeFactoryanno - the qualifier to check for an aliasprotected Map<String,UnitsRelations> getUnitsRel()
protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers()
AnnotatedTypeFactorySubclasses may override this method and to return an immutable set of their supported type qualifiers through one of the 5 approaches shown below.
Subclasses should not call this method; they should call
AnnotatedTypeFactory.getSupportedTypeQualifiers() instead.
By default, a checker supports PolyAll, and all annotations located
in a subdirectory called qual that's located in the same directory
as the checker. Note that only annotations defined with the
@Target({ElementType.TYPE_USE}) meta-annotation (and optionally with
the additional value of ElementType.TYPE_PARAMETER, but no other
ElementType values) are automatically considered as supported
annotations.
Annotations located outside the qual subdirectory, or has other
ElementType values must be explicitly listed in code by overriding
the
AnnotatedTypeFactory.createSupportedTypeQualifiers()
method, as shown below.
Lastly, for checkers that do not want to support PolyAll, it must
also be explicitly written in code, as shown below.
In total, there are 5 ways to indicate annotations that are supported by a checker:
PolyAll:
This is the default behavior. Simply place those annotations within the qual directory.
PolyAll:
Place those annotations within the qual directory, and override
AnnotatedTypeFactory.createSupportedTypeQualifiers() by calling
AnnotatedTypeFactory.getBundledTypeQualifiersWithPolyAll(Class...) with no
parameters passed in. Code example:
@Override protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers() {
return getBundledTypeQualifiersWithoutPolyAll();
}
PolyAll, and a list of other annotations:
Place those annotations within the qual directory, and override
AnnotatedTypeFactory.createSupportedTypeQualifiers() by calling
AnnotatedTypeFactory.getBundledTypeQualifiersWithPolyAll(Class...) with a
varargs parameter list of the other annotations. Code example:
@Override protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers() {
return getBundledTypeQualifiersWithPolyAll(Regex.class, PartialRegex.class, RegexBottom.class, UnknownRegex.class);
}
PolyAll:
Place those annotations within the qual directory, and override
AnnotatedTypeFactory.createSupportedTypeQualifiers() by calling
AnnotatedTypeFactory.getBundledTypeQualifiersWithoutPolyAll(Class...) with a
varargs parameter list of the other annotations. Code example:
@Override protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers() {
return getBundledTypeQualifiersWithoutPolyAll(UnknownFormat.class, FormatBottom.class);
}
AnnotatedTypeFactory.createSupportedTypeQualifiers() and return an immutable
set of the supported annotations. Code example:
@Override protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers() {
return Collections.unmodifiableSet(
new HashSet<Class<? extends Annotation>>(
Arrays.asList(A.class, B.class)));
}
The set of qualifiers returned by
AnnotatedTypeFactory.createSupportedTypeQualifiers() must be an immutable
set. The methods
AnnotatedTypeFactory.getBundledTypeQualifiersWithoutPolyAll(Class...) and
AnnotatedTypeFactory.getBundledTypeQualifiersWithPolyAll(Class...) each
return an immutable set.
createSupportedTypeQualifiers in class AnnotatedTypeFactorypublic TreeAnnotator createTreeAnnotator()
GenericAnnotatedTypeFactoryTreeAnnotator that adds annotations to a type based
on the contents of a tree.
Subclasses may override this method to specify a more appropriate
TreeAnnotator.createTreeAnnotator in class GenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>public QualifierHierarchy createQualifierHierarchy(MultiGraphQualifierHierarchy.MultiGraphFactory factory)
createQualifierHierarchy in class AnnotatedTypeFactory