Class CalledMethodsAnnotatedTypeFactory
- All Implemented Interfaces:
AnnotationProvider
- Direct Known Subclasses:
ResourceLeakAnnotatedTypeFactory
-
Nested Class Summary
Nested classes/interfaces inherited from class org.checkerframework.common.accumulation.AccumulationAnnotatedTypeFactory
AccumulationAnnotatedTypeFactory.AccumulationQualifierHierarchy, AccumulationAnnotatedTypeFactory.AccumulationTreeAnnotator
Nested classes/interfaces inherited from class org.checkerframework.framework.type.GenericAnnotatedTypeFactory
GenericAnnotatedTypeFactory.ScanState
Nested classes/interfaces inherited from class org.checkerframework.framework.type.AnnotatedTypeFactory
AnnotatedTypeFactory.ParameterizedExecutableType
-
Field Summary
Fields inherited from class org.checkerframework.common.accumulation.AccumulationAnnotatedTypeFactory
accumulationChecker, bottom, top
Fields inherited from class org.checkerframework.framework.type.GenericAnnotatedTypeFactory
analysis, arraysAreRelevant, 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
Fields inherited from class org.checkerframework.framework.type.AnnotatedTypeFactory
ajavaTypes, annotatedForValueElement, artificialTreeToEnclosingElementMap, checker, currentFileAjavaTypes, elements, ensuresQualifierExpressionElement, ensuresQualifierIfExpressionElement, ensuresQualifierIfListTM, ensuresQualifierIfListValueElement, ensuresQualifierIfResultElement, ensuresQualifierIfTM, ensuresQualifierListTM, ensuresQualifierListValueElement, ensuresQualifierTM, fieldInvariantFieldElement, fieldInvariantQualifierElement, fromExpressionTreeCache, fromMemberTreeCache, fromTypeTreeCache, hasQualifierParameterValueElement, ignoreUninferredTypeArguments, loader, methodValClassNameElement, methodValMethodNameElement, methodValParamsElement, noQualifierParameterValueElement, objectGetClass, processingEnv, qualHierarchy, qualifierUpperBounds, reflectionResolver, requiresQualifierExpressionElement, requiresQualifierListTM, requiresQualifierListValueElement, requiresQualifierTM, root, shouldCache, stubTypes, trees, typeArgumentInference, typeFormatter, typeHierarchy, types, typeVarSubstitutor, uid, wpiOutputFormat
-
Constructor Summary
ConstructorDescriptionCreate a new CalledMethodsAnnotatedTypeFactory. -
Method Summary
Modifier and TypeMethodDescriptionadjustMethodNameUsingValueChecker
(String methodName, MethodInvocationTree tree) Given a tree, returns the name of the method that the tree should be considered as calling.protected CalledMethodsAnalysis
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 aRequiresQualifier("...")
orEnsuresQualifier("...")
annotation for the given expression.protected TreeAnnotator
Returns aTreeAnnotator
that adds annotations to a type based on the contents of a tree.protected TypeAnnotator
Returns aDefaultForTypeAnnotator
that adds annotations to a type based on the content of the type itself.getDummyAssignedTo
(ExpressionTree expressionTree) Returns the annotation type mirror for the type ofexpressionTree
with default annotations applied.boolean
Returns true if the return type of the given method invocation tree has an @This annotation from the Returns Receiver Checker.Methods inherited from class org.checkerframework.common.accumulation.AccumulationAnnotatedTypeFactory
convertToPredicate, createAccumulatorAnnotation, createAccumulatorAnnotation, createPredicateAnnotation, createQualifierHierarchy, evaluatePredicate, evaluatePredicate, getAccumulatedValues, getAccumulatedValues, isAccumulatorAnnotation, isPredicate, isPredicateSubtype
Methods inherited from class org.checkerframework.framework.type.GenericAnnotatedTypeFactory
addAnnotationsFromDefaultForType, addCheckedCodeDefaults, addCheckedStandardDefaults, addComputedTypeAnnotations, addComputedTypeAnnotations, addComputedTypeAnnotations, addComputedTypeAnnotationsForWarnRedundant, addDefaultAnnotations, addSharedCFGForTree, addUncheckedStandardDefaults, analyze, annotationsForIrrelevantJavaType, 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, getDefaultAnnotations, getDefaultAnnotationsForWarnRedundant, 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, getTypeFactoryOfSubcheckerOrNull, handleCFGViz, irrelevantExtraMessage, isRelevant, isRelevant, isRelevantImpl, methodFromUse, methodFromUsePreSubstitution, parseJavaExpressionString, performFlowAnalysis, postAnalyze, postAsMemberOf, postDirectSuperTypes, postInit, preProcessClassTree, setRoot, typeVariablesFromUse
Methods inherited from class org.checkerframework.framework.type.AnnotatedTypeFactory
adaptGetClassReturnTypeToReceiver, 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, getEnclosingSubType, getEnclosingType, getEnumConstructorQualifiers, 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, initializeReflectionResolution, isFromByteCode, isFromStubFile, isImmutable, isSideEffectFree, isSupportedQualifier, isSupportedQualifier, isSupportedQualifier, isWithinConstructor, logGat, makeConditionConsistentWithOtherMethod, mergeAnnotationFileAnnosIntoType, methodFromUse, negateConstant, order, parseAnnotationFiles, postProcessClassTree, replaceAnnotations, replaceAnnotations, setEnclosingElementForArtificialTree, setVisitorTreePath, shouldWarnIfStubRedundantWithBytecode, toAnnotatedType, toString, type, wpiAdjustForUpdateField, wpiAdjustForUpdateNonField, wpiPrepareMethodForWriting, wpiPrepareMethodForWriting, wpiShouldInferTypesForReceivers
-
Constructor Details
-
CalledMethodsAnnotatedTypeFactory
Create a new CalledMethodsAnnotatedTypeFactory.- Parameters:
checker
- the checker
-
-
Method Details
-
createTreeAnnotator
Description copied from class:GenericAnnotatedTypeFactory
Returns aTreeAnnotator
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 subtreesLiteralTreeAnnotator
: Adds annotations based onQualifierForLiterals
meta-annotationsDependentTypesTreeAnnotator
: 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));
- Overrides:
createTreeAnnotator
in classAccumulationAnnotatedTypeFactory
- Returns:
- a tree annotator
-
createTypeAnnotator
Description copied from class:GenericAnnotatedTypeFactory
Returns aDefaultForTypeAnnotator
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.
- Overrides:
createTypeAnnotator
in classGenericAnnotatedTypeFactory<AccumulationValue,
AccumulationStore, AccumulationTransfer, AccumulationAnalysis> - Returns:
- a type annotator
-
returnsThis
Description copied from class:AccumulationAnnotatedTypeFactory
Returns true if the return type of the given method invocation tree has an @This annotation from the Returns Receiver Checker.- Overrides:
returnsThis
in classAccumulationAnnotatedTypeFactory
- Parameters:
tree
- a method invocation tree- Returns:
- true if the method being invoked returns its receiver
-
adjustMethodNameUsingValueChecker
Given a tree, returns the name of the method that the tree should be considered as calling. Returns "withOwners" if the call sets an "owner", "owner-alias", or "owner-id" filter. Returns "withImageIds" if the call sets an "image-ids" filter.Package-private to permit calls from
CalledMethodsTransfer
.- Parameters:
methodName
- the name of the method being explicitly calledtree
- the invocation of the method- Returns:
- "withOwners" or "withImageIds" if the tree is an equivalent filter addition. Otherwise, return the first argument.
-
createFlowAnalysis
Description copied from class:GenericAnnotatedTypeFactory
Returns the appropriate flow analysis class that is used for the org.checkerframework.dataflow analysis.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.
- Overrides:
createFlowAnalysis
in classGenericAnnotatedTypeFactory<AccumulationValue,
AccumulationStore, AccumulationTransfer, AccumulationAnalysis> - Returns:
- the appropriate flow analysis class that is used for the org.checkerframework.dataflow analysis
-
getDummyAssignedTo
Returns the annotation type mirror for the type ofexpressionTree
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.- Overrides:
getDummyAssignedTo
in classAnnotatedTypeFactory
- Parameters:
expressionTree
- an expression which has no assignment context and for which type arguments need to be inferred- Returns:
null
or an annotated type mirror that inferrence should pretendexpressionTree
is assigned to
-
createRequiresOrEnsuresQualifier
protected @Nullable AnnotationMirror createRequiresOrEnsuresQualifier(String expression, AnnotationMirror qualifier, AnnotatedTypeMirror declaredType, Analysis.BeforeOrAfter preOrPost, @Nullable List<AnnotationMirror> preconds) Description copied from class:GenericAnnotatedTypeFactory
Creates aRequiresQualifier("...")
orEnsuresQualifier("...")
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 stringexpression
and MyQual is the annotation represented byqualifier
.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.- Overrides:
createRequiresOrEnsuresQualifier
in classGenericAnnotatedTypeFactory<AccumulationValue,
AccumulationStore, AccumulationTransfer, AccumulationAnalysis> - Parameters:
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 whenpreOrPost
isBeforeOrAfter.BEFORE
- Returns:
- a
RequiresQualifier("...")
orEnsuresQualifier("...")
annotation for the given expression, or null
-