Class CalledMethodsAnnotatedTypeFactory
- All Implemented Interfaces:
AnnotationProvider
- Direct Known Subclasses:
RLCCalledMethodsAnnotatedTypeFactory
-
Nested Class Summary
Nested classes/interfaces inherited from class org.checkerframework.common.accumulation.AccumulationAnnotatedTypeFactory
AccumulationAnnotatedTypeFactory.AccumulationQualifierHierarchy, AccumulationAnnotatedTypeFactory.AccumulationTreeAnnotatorNested classes/interfaces inherited from class org.checkerframework.framework.type.GenericAnnotatedTypeFactory
GenericAnnotatedTypeFactory.ScanStateNested classes/interfaces inherited from class org.checkerframework.framework.type.AnnotatedTypeFactory
AnnotatedTypeFactory.CapturedTypeVarSubstitutor, AnnotatedTypeFactory.ParameterizedExecutableType -
Field Summary
Fields inherited from class org.checkerframework.common.accumulation.AccumulationAnnotatedTypeFactory
accumulationChecker, bottom, topFields 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, typeAnnotatorFields inherited from class org.checkerframework.framework.type.AnnotatedTypeFactory
ajavaTypes, annotatedForValueElement, artificialTreeToEnclosingElementMap, capturedTypeVarSubstitutor, checker, currentFileAjavaTypes, elements, ensuresQualifierExpressionElement, ensuresQualifierIfExpressionElement, ensuresQualifierIfListTM, ensuresQualifierIfListValueElement, ensuresQualifierIfResultElement, ensuresQualifierIfTM, ensuresQualifierListTM, ensuresQualifierListValueElement, ensuresQualifierTM, fieldInvariantFieldElement, fieldInvariantQualifierElement, fromExpressionTreeCache, fromMemberTreeCache, fromTypeTreeCache, hasQualifierParameterValueElement, ignoreRawTypeArguments, loader, methodValClassNameElement, methodValMethodNameElement, methodValParamsElement, noQualifierParameterValueElement, objectGetClass, processingEnv, qualHierarchy, qualifierUpperBounds, reflectionResolver, requiresQualifierExpressionElement, requiresQualifierListTM, requiresQualifierListValueElement, requiresQualifierTM, root, shouldCache, stubTypes, trees, typeArgumentInference, typeFormatter, typeHierarchy, typeInformationPresenter, types, typeVarSubstitutor, uid, wpiOutputFormat -
Constructor Summary
ConstructorsConstructorDescriptionCreate 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 CalledMethodsAnalysisReturns the appropriate flow analysis class that is used for the org.checkerframework.dataflow analysis.protected @Nullable AnnotationMirrorcreateRequiresOrEnsuresQualifier(String expression, AnnotationMirror qualifier, AnnotatedTypeMirror declaredType, Analysis.BeforeOrAfter preOrPost, @Nullable List<AnnotationMirror> preconds) Creates aRequiresQualifier("...")orEnsuresQualifier("...")annotation for the given expression.protected TreeAnnotatorReturns aTreeAnnotatorthat adds annotations to a type based on the contents of a tree.protected TypeAnnotatorReturns aDefaultForTypeAnnotatorthat adds annotations to a type based on the content of the type itself.getCalledMethods(AnnotationMirror calledMethodsAnnotation) Get the called methods specified by the givenCalledMethodsannotation.getDummyAssignedTo(ExpressionTree expressionTree) Returns the annotation type mirror for the type ofexpressionTreewith default annotations applied.getExceptionalPostconditions(ExecutableElement methodOrConstructor) Get the exceptional postconditions for the given method from theEnsuresCalledMethodsOnExceptionannotations on it.booleanisIgnoredExceptionType(TypeMirror exceptionType) Returns true if the checker should ignore exceptional control flow due to the given exception type.booleanReturns 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, isPredicateSubtypeMethods 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, getReturnStatementStores, getSharedCFGForTree, getShouldDefaultTypeVarLocals, getSortedQualifierNames, getStoreAfter, getStoreAfter, getStoreAfter, getStoreBefore, getStoreBefore, getStoreBefore, getSupportedMonotonicTypeQualifiers, getTypeFactoryOfSubchecker, getTypeFactoryOfSubcheckerOrNull, handleCFGViz, irrelevantExtraMessage, isRelevant, isRelevant, isRelevantImpl, isUnreachable, methodFromUse, methodFromUsePreSubstitution, parseJavaExpressionString, performFlowAnalysis, postAnalyze, postAsMemberOf, postDirectSuperTypes, postInit, preProcessClassTree, setRoot, typeVariablesFromUseMethods 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, constructorFromUse, constructorFromUseWithoutTypeArgInference, containsCapturedTypes, containsSameByClass, createAnnotatedTypeFormatter, createAnnotationClassLoader, createAnnotationFormatter, createQualifierUpperBounds, createSupportedTypeQualifiers, createTypeArgumentInference, createTypeHierarchy, createTypeInformationPresenter, createTypeVariableSubstitutor, declarationFromElement, doesAnnotatedForApplyToThisChecker, fromElement, fromElement, fromElement, getAnnotatedNullType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedTypeFormatter, getAnnotatedTypeFromTypeTree, getAnnotationByClass, getAnnotationFormatter, getAnnotationMirror, getAnnotationWithMetaAnnotation, getBoxedType, getBundledTypeQualifiers, getCacheSize, getChecker, getCheckerNames, getContractExpressions, getContractListValues, 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, getResultingTypeOfConstructorMemberReference, getSelfType, getStringType, getSupportedTypeQualifierNames, getSupportedTypeQualifiers, getTreeUtils, getTypeArgumentInference, getTypeDeclarationBounds, getTypeHierarchy, getTypeOfExtendsImplements, getTypeVarSubstitutor, getUnboxedType, getVisitorTreePath, getWholeProgramInference, getWidenedAnnotations, getWidenedType, getWidenedType, hasExplicitNoQualifierParameterInHierarchy, hasExplicitQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, initializeAtm, initializeReflectionResolution, isDeterministic, isFromByteCode, isFromStubFile, isImmutable, isSideEffectFree, isSupportedQualifier, isSupportedQualifier, isSupportedQualifier, isTop, isWithinConstructor, logGat, makeConditionConsistentWithOtherMethod, mergeAnnotationFileAnnosIntoType, methodFromUse, methodFromUse, methodFromUse, methodFromUseWithoutTypeArgInference, methodFromUseWithoutTypeArgInference, 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:GenericAnnotatedTypeFactoryReturns aTreeAnnotatorthat adds annotations to a type based on the contents of a tree.The default tree annotator is a
ListTreeAnnotatorof the following:PropagationTreeAnnotator: Propagates annotations from subtreesLiteralTreeAnnotator: Adds annotations based onQualifierForLiteralsmeta-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:
createTreeAnnotatorin classAccumulationAnnotatedTypeFactory- Returns:
- a tree annotator
-
createTypeAnnotator
Description copied from class:GenericAnnotatedTypeFactoryReturns aDefaultForTypeAnnotatorthat adds annotations to a type based on the content of the type itself.Subclass may override this method. The default type annotator is a
ListTypeAnnotatorof the following:IrrelevantTypeAnnotator: Adds top to types not listed in the@RelevantJavaTypesannotation on the checker.PropagationTypeAnnotator: Propagates annotation onto wildcards.
- Overrides:
createTypeAnnotatorin classGenericAnnotatedTypeFactory<AccumulationValue,AccumulationStore, AccumulationTransfer, AccumulationAnalysis> - Returns:
- a type annotator
-
returnsThis
Description copied from class:AccumulationAnnotatedTypeFactoryReturns true if the return type of the given method invocation tree has an @This annotation from the Returns Receiver Checker.- Overrides:
returnsThisin 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:GenericAnnotatedTypeFactoryReturns 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:
createFlowAnalysisin 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 ofexpressionTreewith 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:
getDummyAssignedToin classAnnotatedTypeFactory- Parameters:
expressionTree- an expression which has no assignment context and for which type arguments need to be inferred- Returns:
nullor an annotated type mirror that inferrence should pretendexpressionTreeis assigned to
-
getCalledMethods
Get the called methods specified by the givenCalledMethodsannotation.- Parameters:
calledMethodsAnnotation- the annotation- Returns:
- the called methods
-
createRequiresOrEnsuresQualifier
protected @Nullable AnnotationMirror createRequiresOrEnsuresQualifier(String expression, AnnotationMirror qualifier, AnnotatedTypeMirror declaredType, Analysis.BeforeOrAfter preOrPost, @Nullable List<AnnotationMirror> preconds) Description copied from class:GenericAnnotatedTypeFactoryCreates 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 stringexpressionand 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
@RequiresQualifierand@EnsuresQualifierdo not support. Subclasses may override this method to return qualifiers that do have arguments instead of returning null.- Overrides:
createRequiresOrEnsuresQualifierin 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 whenpreOrPostisBeforeOrAfter.BEFORE- Returns:
- a
RequiresQualifier("...")orEnsuresQualifier("...")annotation for the given expression, or null
-
isIgnoredExceptionType
Returns true if the checker should ignore exceptional control flow due to the given exception type.- Overrides:
isIgnoredExceptionTypein classGenericAnnotatedTypeFactory<AccumulationValue,AccumulationStore, AccumulationTransfer, AccumulationAnalysis> - Parameters:
exceptionType- exception type- Returns:
trueifexceptionTypeis a member ofCalledMethodsAnalysis.ignoredExceptionTypes,falseotherwise
-
getExceptionalPostconditions
public Set<EnsuresCalledMethodOnExceptionContract> getExceptionalPostconditions(ExecutableElement methodOrConstructor) Get the exceptional postconditions for the given method from theEnsuresCalledMethodsOnExceptionannotations on it.- Parameters:
methodOrConstructor- the method to examine- Returns:
- the exceptional postconditions on the given method; the return value is newly-allocated and can be freely modified by callers
-