public abstract class AccumulationAnnotatedTypeFactory extends BaseAnnotatedTypeFactory
New accumulation checkers should extend this class and implement a constructor, which should
take a BaseTypeChecker and call both the constructor defined in this class and GenericAnnotatedTypeFactory.postInit().
| Modifier and Type | Class and Description |
|---|---|
protected class |
AccumulationAnnotatedTypeFactory.AccumulationQualifierHierarchy
All accumulation analyses share a similar type hierarchy.
|
protected class |
AccumulationAnnotatedTypeFactory.AccumulationTreeAnnotator
This tree annotator implements the following rule(s):
RRA
If a method returns its receiver, and the receiver has an accumulation type, then the
default type of the method's return value is the type of the receiver.
|
GenericAnnotatedTypeFactory.ScanStateAnnotatedTypeFactory.ParameterizedExecutableType| Modifier and Type | Field and Description |
|---|---|
AnnotationMirror |
bottom
The canonical bottom annotation for this accumulation checker.
|
AnnotationMirror |
top
The canonical top annotation for this accumulation checker: an instance of the accumulator
annotation with no arguments.
|
analysis, cfgVisualizer, defaults, dependentTypesHelper, emptyStore, exceptionalExitStores, flowByDefault, flowResult, flowResultAnalysisCaches, initializationStaticStore, initializationStore, methodInvocationStores, poly, regularExitStores, returnStatementStores, scannedClasses, transfer, treeAnnotator, typeAnnotatorchecker, elements, fromExpressionTreeCache, fromMemberTreeCache, fromTypeTreeCache, ignoreUninferredTypeArguments, loader, objectGetClass, processingEnv, qualHierarchy, qualifierUpperBounds, reflectionResolver, root, shouldCache, stubTypes, trees, typeArgumentInference, typeFormatter, typeHierarchy, types, typeVarSubstitutor, uid, visitorState| Modifier | Constructor and Description |
|---|---|
protected |
AccumulationAnnotatedTypeFactory(BaseTypeChecker checker,
Class<? extends Annotation> accumulator,
Class<? extends Annotation> bottom)
Create an annotated type factory for an accumulation checker.
|
protected |
AccumulationAnnotatedTypeFactory(BaseTypeChecker checker,
Class<? extends Annotation> accumulator,
Class<? extends Annotation> bottom,
@Nullable Class<? extends Annotation> predicate)
Create an annotated type factory for an accumulation checker.
|
| Modifier and Type | Method and Description |
|---|---|
protected String |
convertToPredicate(AnnotationMirror anno)
Converts the given annotation mirror to a predicate.
|
AnnotationMirror |
createAccumulatorAnnotation(List<String> values)
Creates a new instance of the accumulator annotation that contains the elements of
values. |
AnnotationMirror |
createAccumulatorAnnotation(String value)
Creates a new instance of the accumulator annotation that contains exactly one value.
|
protected AnnotationMirror |
createPredicateAnnotation(String p)
Creates a new predicate annotation from the given string.
|
QualifierHierarchy |
createQualifierHierarchy(MultiGraphQualifierHierarchy.MultiGraphFactory factory)
Factory method to easily change what QualifierHierarchy is created.
|
protected TreeAnnotator |
createTreeAnnotator()
Returns a
TreeAnnotator that adds annotations to a type based on the contents of a
tree. |
protected boolean |
evaluatePredicate(AnnotationMirror subAnno,
String pred)
Evaluates whether the accumulator annotation
subAnno makes the predicate pred
true. |
protected boolean |
evaluatePredicate(List<String> trueVariables,
String pred)
Evaluates whether treating the variables in
trueVariables as true literals
(and all other names as false literals) makes the predicate pred evaluate to
true. |
List<String> |
getAccumulatedValues(AnnotationMirror anno)
Returns all the values that anno has accumulated.
|
boolean |
isAccumulatorAnnotation(AnnotationMirror anm)
Is the given annotation an accumulator annotation? Returns false if the argument is
bottom. |
protected boolean |
isPredicate(AnnotationMirror anno)
Returns true if anno is a predicate annotation.
|
protected boolean |
isPredicateSubtype(String p,
String q)
Extension point for subtyping behavior between predicates.
|
boolean |
returnsThis(MethodInvocationTree tree)
Returns true if the return type of the given method invocation tree has an @This annotation
from the Returns Receiver Checker.
|
createFlowAnalysisaddAnnotationsFromDefaultForType, addCheckedCodeDefaults, addCheckedStandardDefaults, addComputedTypeAnnotations, addComputedTypeAnnotations, addComputedTypeAnnotations, addDefaultAnnotations, addUncheckedStandardDefaults, analyze, applyInferredAnnotations, applyQualifierParameterDefaults, applyQualifierParameterDefaults, checkAndPerformFlowAnalysis, checkForDefaultQualifierInHierarchy, constructorFromUse, constructorFromUsePreSubstitution, createAndInitQualifierDefaults, createCFGVisualizer, createDefaultForTypeAnnotator, createDefaultForUseTypeAnnotator, createDependentTypesHelper, createFlowTransferFunction, createQualifierDefaults, createQualifierPolymorphism, createTypeAnnotator, fromNewClass, getAnnotatedTypeLhs, getAnnotatedTypeLhsNoTypeVarDefault, getAnnotatedTypeRhsUnaryAssign, getAnnotatedTypeVarargsArray, getAnnotationFromJavaExpressionString, getAnnotationFromReceiver, getAnnotationMirrorFromJavaExpressionString, getCFGVisualizer, getDependentTypesHelper, getEmptyStore, getExceptionalExitStore, getFinalLocalValues, getFirstNodeOfKindForTree, getInferredValueFor, getMethodReturnType, getMethodReturnType, getNodesForTree, getQualifierPolymorphism, getReceiverAndOffsetFromJavaExpressionString, getReceiverFromJavaExpressionString, getRegularExitStore, getResultingTypeOfConstructorMemberReference, getReturnStatementStores, getShouldDefaultTypeVarLocals, getSortedQualifierNames, getStoreAfter, getStoreAfter, getStoreAfter, getStoreBefore, getStoreBefore, getStoreBefore, getSupportedMonotonicTypeQualifiers, getTypeFactoryOfSubchecker, handleCFGViz, methodFromUse, methodFromUsePreSubstitution, performFlowAnalysis, postAnalyze, postAsMemberOf, postDirectSuperTypes, postInit, preProcessClassTree, setRoot, typeVariablesFromUseadaptGetClassReturnTypeToReceiver, addAliasedAnnotation, addAliasedAnnotation, addAliasedAnnotation, addAliasedAnnotation, addAliasedDeclAnnotation, addAnnotationFromFieldInvariant, addInheritedAnnotation, areSameByClass, canonicalAnnotation, checkInvalidOptionsInferSignatures, containsSameByClass, createAnnotatedTypeFormatter, createAnnotationClassLoader, createAnnotationFormatter, createQualifierHierarchy, createQualifierHierarchy, createQualifierHierarchyFactory, createQualifierUpperBounds, createSupportedTypeQualifiers, createTypeArgumentInference, createTypeHierarchy, createTypeVariableSubstitutor, declarationFromElement, fromElement, fromElement, fromElement, getAnnotatedNullType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedTypeFormatter, getAnnotatedTypeFromTypeTree, getAnnotationByClass, getAnnotationFormatter, getAnnotationMirror, getAnnotationWithMetaAnnotation, getBoxedType, getBundledTypeQualifiers, getCacheSize, getContext, getCurrentClassTree, getCurrentClassType, getCurrentMethodReceiver, getDeclAnnotation, getDeclAnnotationNoAliases, getDeclAnnotations, getDeclAnnotationWithMetaAnnotation, getDefaultTypeDeclarationBounds, getDummyAssignedTo, getElementUtils, getEnclosingElementForArtificialTree, getEnclosingType, getExpressionAndOffset, getFieldInvariantAnnotationTree, getFieldInvariantDeclarationAnnotations, getFieldInvariants, getFnInterfaceFromTree, getFunctionTypeFromTree, getFunctionTypeFromTree, getImplicitReceiverType, getNarrowedPrimitive, getPath, getProcessingEnv, getQualifierHierarchy, getQualifierParameterHierarchies, getQualifierParameterHierarchies, getQualifierUpperBounds, getReceiverType, getSelfType, getStringType, getSupportedTypeQualifierNames, getSupportedTypeQualifiers, getTreeUtils, getTypeArgumentInference, getTypeDeclarationBounds, getTypeHierarchy, getTypeOfExtendsImplements, getTypeVarSubstitutor, getUnboxedType, getUninferredWildcardType, getVisitorState, getWholeProgramInference, hasExplicitNoQualifierParameterInHierarchy, hasExplicitQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, initializeReflectionResolution, isAnyEnclosingThisDeref, isFromByteCode, isFromStubFile, isMostEnclosingThisDeref, isSupportedQualifier, isSupportedQualifier, isSupportedQualifier, isWithinConstructor, mergeStubsIntoType, methodFromUse, negateConstant, parseStubFiles, postProcessClassTree, postTypeVarSubstitution, setEnclosingElementForArtificialTree, shouldWarnIfStubRedundantWithBytecode, toAnnotatedType, toString, type, widenToUpperBoundpublic final AnnotationMirror top
public final AnnotationMirror bottom
protected AccumulationAnnotatedTypeFactory(BaseTypeChecker checker, Class<? extends Annotation> accumulator, Class<? extends Annotation> bottom, @Nullable Class<? extends Annotation> predicate)
checker - the checkeraccumulator - the accumulator type in the hierarchy. Must be an annotation with a single
argument named "value" whose type is a String array.bottom - the bottom type in the hierarchy, which must be a subtype of accumulator. The bottom type should be an annotation with no arguments.predicate - the predicate annotation. Either null (if predicates are not supported), or
an annotation with a single element named "value" whose type is a String.protected AccumulationAnnotatedTypeFactory(BaseTypeChecker checker, Class<? extends Annotation> accumulator, Class<? extends Annotation> bottom)
checker - the checkeraccumulator - the accumulator type in the hierarchy. Must be an annotation with a single
argument named "value" whose type is a String array.bottom - the bottom type in the hierarchy, which must be a subtype of accumulator. The bottom type should be an annotation with no arguments.public AnnotationMirror createAccumulatorAnnotation(List<String> values)
values.values - the arguments to the annotation. The values can contain duplicates and can be
in any order.values's
arguments; this is top if values is emptypublic AnnotationMirror createAccumulatorAnnotation(String value)
value - the argument to the annotationvalue as
its argumentpublic boolean returnsThis(MethodInvocationTree tree)
tree - a method invocation treepublic boolean isAccumulatorAnnotation(AnnotationMirror anm)
bottom.anm - an annotation mirrorprotected TreeAnnotator createTreeAnnotator()
GenericAnnotatedTypeFactoryTreeAnnotator that adds annotations to a type based on the contents of a
tree.
The default tree annotator is a ListTreeAnnotator of the following:
PropagationTreeAnnotator: Propagates annotations from subtrees
LiteralTreeAnnotator: Adds annotations based on QualifierForLiterals
meta-annotations
DependentTypesTreeAnnotator: Adapts dependent annotations based on context
Subclasses may override this method to specify additional tree annotators, for example:
new ListTreeAnnotator(super.createTreeAnnotator(), new KeyLookupTreeAnnotator(this));
createTreeAnnotator in class GenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>public QualifierHierarchy createQualifierHierarchy(MultiGraphQualifierHierarchy.MultiGraphFactory factory)
AnnotatedTypeFactorycreateQualifierHierarchy in class AnnotatedTypeFactorypublic List<String> getAccumulatedValues(AnnotationMirror anno)
anno - an accumulator annotation; must not be bottomprotected boolean isPredicateSubtype(String p, String q)
p - a predicateq - another predicateprotected boolean evaluatePredicate(AnnotationMirror subAnno, String pred)
subAnno makes the predicate pred
true.subAnno - an accumulator annotationpred - a predicateprotected boolean evaluatePredicate(List<String> trueVariables, String pred)
trueVariables as true literals
(and all other names as false literals) makes the predicate pred evaluate to
true.trueVariables - a list of names that should be replaced with truepred - a predicateprotected AnnotationMirror createPredicateAnnotation(String p)
p - a valid predicateprotected String convertToPredicate(AnnotationMirror anno)
anno - an annotationprotected boolean isPredicate(AnnotationMirror anno)
anno - an annotation