public class CalledMethodsAnnotatedTypeFactory extends AccumulationAnnotatedTypeFactory
AccumulationAnnotatedTypeFactory.AccumulationQualifierHierarchy, AccumulationAnnotatedTypeFactory.AccumulationTreeAnnotator
GenericAnnotatedTypeFactory.ScanState
AnnotatedTypeFactory.ParameterizedExecutableType
accumulationChecker, bottom, top
analysis, cfgVisualizer, contractsUtils, defaults, dependentTypesHelper, emptyStore, exceptionalExitStores, flowByDefault, flowResult, flowResultAnalysisCaches, formalParameterPattern, hasOrIsSubchecker, initializationStaticStore, initializationStore, methodInvocationStores, poly, regularExitStores, relevantJavaTypes, returnStatementStores, scannedClasses, shouldClearSubcheckerSharedCFGs, sideEffectsUnrefineAliases, subcheckerSharedCFG, transfer, treeAnnotator, typeAnnotator
ajavaTypes, artificialTreeToEnclosingElementMap, checker, currentFileAjavaTypes, elements, fromExpressionTreeCache, fromMemberTreeCache, fromTypeTreeCache, ignoreUninferredTypeArguments, loader, methodValClassNameElement, methodValMethodNameElement, methodValParamsElement, objectGetClass, processingEnv, qualHierarchy, qualifierUpperBounds, reflectionResolver, root, shouldCache, stubTypes, trees, typeArgumentInference, typeFormatter, typeHierarchy, types, typeVarSubstitutor, uid, wpiOutputFormat
Constructor and Description |
---|
CalledMethodsAnnotatedTypeFactory(BaseTypeChecker checker)
Create a new CalledMethodsAnnotatedTypeFactory.
|
Modifier and Type | Method and Description |
---|---|
String |
adjustMethodNameUsingValueChecker(String methodName,
MethodInvocationTree tree)
Given a tree, returns the name of the method that the tree should be considered as calling.
|
protected CalledMethodsAnalysis |
createFlowAnalysis()
Returns the appropriate flow analysis class that is used for the org.checkerframework.dataflow
analysis.
|
protected @Nullable AnnotationMirror |
createRequiresOrEnsuresQualifier(String expression,
AnnotationMirror qualifier,
AnnotatedTypeMirror declaredType,
Analysis.BeforeOrAfter preOrPost,
@Nullable List<AnnotationMirror> preconds)
Creates a
RequiresQualifier("...") or EnsuresQualifier("...") annotation for
the given expression. |
protected TreeAnnotator |
createTreeAnnotator()
Returns a
TreeAnnotator that adds annotations to a type based on the contents of a
tree. |
protected TypeAnnotator |
createTypeAnnotator()
Returns a
DefaultForTypeAnnotator that adds annotations to a type based on the content
of the type itself. |
@Nullable AnnotatedTypeMirror |
getDummyAssignedTo(ExpressionTree expressionTree)
Returns the annotation type mirror for the type of
expressionTree with default
annotations applied. |
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.
|
convertToPredicate, createAccumulatorAnnotation, createAccumulatorAnnotation, createPredicateAnnotation, createQualifierHierarchy, evaluatePredicate, evaluatePredicate, getAccumulatedValues, isAccumulatorAnnotation, isPredicate, isPredicateSubtype
addAnnotationsFromDefaultForType, addCheckedCodeDefaults, addCheckedStandardDefaults, addComputedTypeAnnotations, addComputedTypeAnnotations, addComputedTypeAnnotations, addDefaultAnnotations, addSharedCFGForTree, addUncheckedStandardDefaults, analyze, applyInferredAnnotations, applyQualifierParameterDefaults, applyQualifierParameterDefaults, checkAndPerformFlowAnalysis, checkForDefaultQualifierInHierarchy, constructorFromUse, constructorFromUsePreSubstitution, createAndInitQualifierDefaults, createCFGVisualizer, createContractsFromMethod, createDefaultForTypeAnnotator, createDefaultForUseTypeAnnotator, createDependentTypesHelper, createFlowTransferFunction, createQualifierDefaults, createQualifierPolymorphism, getAnnotatedTypeLhs, getAnnotatedTypeLhsNoTypeVarDefault, getAnnotatedTypeRhsUnaryAssign, getAnnotatedTypeVarargsArray, getAnnotationFromJavaExpression, getAnnotationFromJavaExpressionString, getAnnotationMirrorFromJavaExpressionString, getAnnotationsFromJavaExpression, getCFGVisualizer, getContractAnnotations, getContractAnnotations, getContractExpressions, getContractsFromMethod, getDefaultForTypeAnnotator, getDefaultValueAnnotatedType, getDependentTypesHelper, getEmptyStore, getEnsuresQualifierIfResult, getExceptionalExitStore, getExplicitNewClassAnnos, getExplicitNewClassClassTypeArgs, getExpressionAndOffsetFromJavaExpressionString, getFinalLocalValues, getFirstNodeOfKindForTree, getInferredValueFor, getMethodReturnType, getNodesForTree, getPostconditionAnnotations, getPostconditionAnnotations, getPostconditionAnnotations, getPreconditionAnnotations, getPreconditionAnnotations, getPreconditionAnnotations, getPreOrPostconditionAnnotations, getQualifierPolymorphism, getRegularExitStore, getResultingTypeOfConstructorMemberReference, getReturnStatementStores, getSharedCFGForTree, getShouldDefaultTypeVarLocals, getSortedQualifierNames, getStoreAfter, getStoreAfter, getStoreAfter, getStoreBefore, getStoreBefore, getStoreBefore, getSupportedMonotonicTypeQualifiers, getTypeFactoryOfSubchecker, handleCFGViz, isRelevant, methodFromUse, methodFromUsePreSubstitution, parseJavaExpressionString, performFlowAnalysis, postAnalyze, postAsMemberOf, postDirectSuperTypes, postInit, preProcessClassTree, setRoot, typeVariablesFromUse
adaptGetClassReturnTypeToReceiver, addAliasedAnnotation, addAliasedAnnotation, addAliasedAnnotation, addAliasedDeclAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAnnotationFromFieldInvariant, addInheritedAnnotation, applyCaptureConversion, applyCaptureConversion, applyUnboxing, areSameByClass, binaryTreeArgTypes, binaryTreeArgTypes, canonicalAnnotation, checkInvalidOptionsInferSignatures, compoundAssignmentTreeArgTypes, containsSameByClass, containsUninferredTypeArguments, createAnnotatedTypeFormatter, createAnnotationClassLoader, createAnnotationFormatter, createQualifierUpperBounds, createSupportedTypeQualifiers, createTypeArgumentInference, createTypeHierarchy, createTypeVariableSubstitutor, declarationFromElement, doesAnnotatedForApplyToThisChecker, fromElement, fromElement, fromElement, fromNewClass, getAnnotatedNullType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedTypeFormatter, getAnnotatedTypeFromTypeTree, getAnnotationByClass, getAnnotationFormatter, getAnnotationMirror, getAnnotationWithMetaAnnotation, getBoxedType, getBundledTypeQualifiers, getCacheSize, getChecker, getCheckerNames, getContractExpressions, getContractListValues, getCurrentClassTree, getCurrentMethodReceiver, getDeclAnnotation, getDeclAnnotationNoAliases, getDeclAnnotations, getDeclAnnotationWithMetaAnnotation, getDefaultTypeDeclarationBounds, getElementUtils, getEnclosingClassOrMethod, getEnclosingElementForArtificialTree, getEnclosingType, getExpressionAndOffset, getFieldInvariantAnnotationTree, getFieldInvariantDeclarationAnnotations, getFieldInvariants, getFnInterfaceFromTree, getFunctionTypeFromTree, getFunctionTypeFromTree, getImplicitReceiverType, getIterableElementType, getIterableElementType, getMethodReturnType, getNarrowedAnnotations, getNarrowedPrimitive, getPath, getProcessingEnv, getQualifierHierarchy, getQualifierParameterHierarchies, getQualifierParameterHierarchies, getQualifierUpperBounds, getReceiverType, getSelfType, getStringType, getSupportedTypeQualifierNames, getSupportedTypeQualifiers, getTreeUtils, getTypeArgumentInference, getTypeDeclarationBounds, getTypeHierarchy, getTypeOfExtendsImplements, getTypeVarSubstitutor, getUnboxedType, getUninferredWildcardType, getVisitorTreePath, getWholeProgramInference, getWidenedAnnotations, getWidenedType, getWidenedType, hasExplicitNoQualifierParameterInHierarchy, hasExplicitQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, initializeAtm, initializeReflectionResolution, isFromByteCode, isFromStubFile, isImmutable, isSupportedQualifier, isSupportedQualifier, isSupportedQualifier, isWithinConstructor, mergeAnnotationFileAnnosIntoType, methodFromUse, negateConstant, order, parseAnnotationFiles, postProcessClassTree, prepareMethodForWriting, prepareMethodForWriting, replaceAnnotations, replaceAnnotations, setEnclosingElementForArtificialTree, setVisitorTreePath, shouldWarnIfStubRedundantWithBytecode, toAnnotatedType, toString, type, wpiAdjustForUpdateField, wpiAdjustForUpdateNonField
public CalledMethodsAnnotatedTypeFactory(BaseTypeChecker checker)
checker
- the checkerprotected TreeAnnotator createTreeAnnotator()
GenericAnnotatedTypeFactory
TreeAnnotator
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 AccumulationAnnotatedTypeFactory
protected TypeAnnotator createTypeAnnotator()
GenericAnnotatedTypeFactory
DefaultForTypeAnnotator
that adds annotations to a type based on the content
of the type itself.
Subclass may override this method. The default type annotator is a ListTypeAnnotator
of the following:
IrrelevantTypeAnnotator
: Adds top to types not listed in the @
RelevantJavaTypes
annotation on the checker.
PropagationTypeAnnotator
: Propagates annotation onto wildcards.
createTypeAnnotator
in class GenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>
public boolean returnsThis(MethodInvocationTree tree)
AccumulationAnnotatedTypeFactory
returnsThis
in class AccumulationAnnotatedTypeFactory
tree
- a method invocation treepublic String adjustMethodNameUsingValueChecker(String methodName, MethodInvocationTree tree)
Package-private to permit calls from CalledMethodsTransfer
.
methodName
- the name of the method being explicitly calledtree
- the invocation of the methodprotected CalledMethodsAnalysis createFlowAnalysis()
GenericAnnotatedTypeFactory
This implementation uses the checker naming convention to create the appropriate analysis.
If no transfer function is found, it returns an instance of CFAnalysis
.
Subclasses have to override this method to create the appropriate analysis if they do not follow the checker naming convention.
createFlowAnalysis
in class BaseAnnotatedTypeFactory
public @Nullable AnnotatedTypeMirror getDummyAssignedTo(ExpressionTree expressionTree)
expressionTree
with default
annotations applied. As types relevant to Called Methods checking are rarely used inside
generics, this is typically the best choice for type inference.getDummyAssignedTo
in class AnnotatedTypeFactory
expressionTree
- an expression which has no assignment context and for which type
arguments need to be inferrednull
or an annotated type mirror that inferrence should pretend expressionTree
is assigned toprotected @Nullable AnnotationMirror createRequiresOrEnsuresQualifier(String expression, AnnotationMirror qualifier, AnnotatedTypeMirror declaredType, Analysis.BeforeOrAfter preOrPost, @Nullable List<AnnotationMirror> preconds)
GenericAnnotatedTypeFactory
RequiresQualifier("...")
or EnsuresQualifier("...")
annotation for
the given expression.
This is of the form @RequiresQualifier(expression="expression",
qualifier=MyQual.class)
or @EnsuresQualifier(expression="expression",
qualifier=MyQual.class)
, where "expression" is exactly the string expression
and
MyQual is the annotation represented by qualifier
.
Returns null if the expression is invalid when combined with the kind of annotation: for example, precondition annotations on "this" and parameters ("#1", etc.) are not supported, because receiver/parameter annotations should be inferred instead.
This implementation returns null if no annotation can be created, because the qualifier has
elements/arguments, which @RequiresQualifier
and @EnsuresQualifier
do not
support. Subclasses may override this method to return qualifiers that do have arguments
instead of returning null.
createRequiresOrEnsuresQualifier
in class GenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>
expression
- the expression to which the qualifier appliesqualifier
- the qualifier that must be presentdeclaredType
- the declared type of the expression, which is used to avoid inferring
redundant pre- or postcondition annotationspreOrPost
- whether to return a precondition or postcondition annotationpreconds
- the list of precondition annotations; used to suppress redundant
postconditions; non-null exactly when preOrPost
is BeforeOrAfter.BEFORE
RequiresQualifier("...")
or EnsuresQualifier("...")
annotation for
the given expression, or null