Class ValueAnnotatedTypeFactory
- java.lang.Object
-
- org.checkerframework.framework.type.AnnotatedTypeFactory
-
- org.checkerframework.framework.type.GenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>
-
- org.checkerframework.common.basetype.BaseAnnotatedTypeFactory
-
- org.checkerframework.common.value.ValueAnnotatedTypeFactory
-
- All Implemented Interfaces:
AnnotationProvider
public class ValueAnnotatedTypeFactory extends BaseAnnotatedTypeFactory
AnnotatedTypeFactory for the Value type system.
-
-
Nested Class Summary
-
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 Modifier and Type Field Description static java.lang.String
ARRAYLEN_NAME
Fully-qualified class name ofArrayLen
.static java.lang.String
ARRAYLENRANGE_NAME
Fully-qualified class name ofArrayLenRange
.protected javax.lang.model.element.ExecutableElement
arrayLenRangeFromElement
The from() element/field of an @ArrayLenRange annotation.protected javax.lang.model.element.ExecutableElement
arrayLenRangeToElement
The to() element/field of an @ArrayLenRange annotation.protected javax.lang.model.element.ExecutableElement
arrayLenValueElement
The value() element/field of an @ArrayLen annotation.javax.lang.model.element.AnnotationMirror
BOOLEAN_FALSE
The canonical @BoolVal
(false) annotation.javax.lang.model.element.AnnotationMirror
BOOLEAN_TRUE
The canonical @BoolVal
(true) annotation.static java.lang.String
BOOLVAL_NAME
Fully-qualified class name ofBoolVal
.protected javax.lang.model.element.ExecutableElement
boolValValueElement
The value() element/field of a @BoolVal annotation.protected javax.lang.model.element.AnnotationMirror
BOTTOMVAL
The bottom type for this hierarchy.static java.lang.String
BOTTOMVAL_NAME
Fully-qualified class name ofBottomVal
.static java.lang.String
DOES_NOT_MATCH_REGEX_NAME
Fully-qualified class name ofDoesNotMatchRegex
.javax.lang.model.element.ExecutableElement
doesNotMatchRegexValueElement
The value() element/field of a @DoesNotMatchRegex annotation.static java.lang.String
DOUBLEVAL_NAME
Fully-qualified class name ofDoubleVal
.protected javax.lang.model.element.ExecutableElement
doubleValValueElement
The value() element/field of a @DoubleVal annotation.protected ReflectiveEvaluator
evaluator
Helper class that evaluates statically executable methods, constructors, and fields.static java.lang.String
INTRANGE_FROMGTENEGONE_NAME
Fully-qualified class name ofIntRangeFromGTENegativeOne
.static java.lang.String
INTRANGE_FROMNONNEG_NAME
Fully-qualified class name ofIntRangeFromNonNegative
.static java.lang.String
INTRANGE_FROMPOS_NAME
Fully-qualified class name ofIntRangeFromPositive
.static java.lang.String
INTRANGE_NAME
Fully-qualified class name ofIntRange
.protected javax.lang.model.element.ExecutableElement
intRangeFromElement
The from() element/field of an @IntRange annotation.protected javax.lang.model.element.ExecutableElement
intRangeToElement
The to() element/field of an @IntRange annotation.static java.lang.String
INTVAL_NAME
Fully-qualified class name ofIntVal
.protected javax.lang.model.element.ExecutableElement
intValValueElement
The value() element/field of a @IntVal annotation.static java.lang.String
MATCHES_REGEX_NAME
Fully-qualified class name ofMatchesRegex
.javax.lang.model.element.ExecutableElement
matchesRegexValueElement
The value() element/field of a @MatchesRegex annotation.protected static int
MAX_VALUES
The maximum number of values allowed in an annotation's array.static java.lang.String
MINLEN_NAME
Fully-qualified class name ofMinLen
.protected javax.lang.model.element.ExecutableElement
minLenFieldInvariantFieldElement
The field() element/field of a @MinLenFieldInvariant annotation.protected javax.lang.model.element.ExecutableElement
minLenFieldInvariantMinLenElement
The minLen() element/field of a @MinLenFieldInvariant annotation.protected javax.lang.model.element.ExecutableElement
minLenValueElement
The value() element/field of a @MinLen annotation.javax.lang.model.element.AnnotationMirror
POLY
The canonical @PolyValue
annotation.static java.lang.String
POLY_NAME
Fully-qualified class name ofPolyValue
.static java.lang.String
STRINGVAL_NAME
Fully-qualified class name ofStringVal
.javax.lang.model.element.ExecutableElement
stringValValueElement
The value() element/field of a @StringVal annotation.static java.lang.String
UNKNOWN_NAME
Fully-qualified class name ofUnknownVal
.protected javax.lang.model.element.AnnotationMirror
UNKNOWNVAL
The top type for this hierarchy.-
Fields inherited from class org.checkerframework.framework.type.GenericAnnotatedTypeFactory
analysis, arraysAreRelevant, cfgVisualizer, contractsUtils, defaults, dependentTypesHelper, emptyStore, exceptionalExitStores, flowByDefault, flowResult, flowResultAnalysisCaches, formalParameterPattern, hasOrIsSubchecker, initializationStaticStore, initializationStore, poly, regularExitStores, relevantJavaTypes, returnStatementStores, scannedClasses, shouldClearSubcheckerSharedCFGs, sideEffectsUnrefineAliases, subcheckerSharedCFG, transfer, treeAnnotator, typeAnnotator
-
Fields inherited from class org.checkerframework.framework.type.AnnotatedTypeFactory
ajavaTypes, annotatedForValueElement, 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, viewpointAdapter
-
-
Constructor Summary
Constructors Constructor Description ValueAnnotatedTypeFactory(BaseTypeChecker checker)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
applyInferredAnnotations(AnnotatedTypeMirror type, CFValue inferred)
Applies the annotations inferred by the org.checkerframework.dataflow analysis to the typetype
.javax.lang.model.element.AnnotationMirror
canonicalAnnotation(javax.lang.model.element.AnnotationMirror anno)
Returns the canonical annotation for the passed annotation.javax.lang.model.element.AnnotationMirror
convertArrayLenToArrayLenRange(javax.lang.model.element.AnnotationMirror arrayLenAnno)
Converts an@ArrayLen
annotation to an@ArrayLenRange
annotation.javax.lang.model.element.AnnotationMirror
convertIntRangeToIntVal(javax.lang.model.element.AnnotationMirror intRangeAnno)
Convert an@IntRange
annotation to an@IntVal
annotation, or to UNKNOWNVAL if the input is too wide to be represented as an@IntVal
.javax.lang.model.element.AnnotationMirror
convertIntValToIntRange(javax.lang.model.element.AnnotationMirror intValAnno)
Converts an@IntVal
annotation to an@IntRange
annotation.javax.lang.model.element.AnnotationMirror
createArrayLenAnnotation(@Nullable java.util.List<java.lang.Integer> values)
Returns aArrayLen
annotation using the values.javax.lang.model.element.AnnotationMirror
createArrayLenRangeAnnotation(int from, int to)
Create an@ArrayLenRange
annotation from the two (inclusive) bounds.javax.lang.model.element.AnnotationMirror
createArrayLenRangeAnnotation(Range range)
Create an@ArrayLenRange
annotation from the range.javax.lang.model.element.AnnotationMirror
createBooleanAnnotation(@Nullable java.util.List<java.lang.Boolean> values)
Returns aBoolVal
annotation using the values.javax.lang.model.element.AnnotationMirror
createCharAnnotation(@Nullable java.util.List<java.lang.Character> values)
Returns aIntVal
annotation using the values.javax.lang.model.element.AnnotationMirror
createDoesNotMatchRegexAnnotation(@Nullable java.util.List<@Regex java.lang.String> regexes)
Creates anDoesNotMatchRegex
annotation for the given regular expressions.javax.lang.model.element.AnnotationMirror
createDoubleAnnotation(@Nullable java.util.List<java.lang.Double> values)
Returns aDoubleVal
annotation using the values.javax.lang.model.element.AnnotationMirror
createDoubleValAnnotation(@Nullable java.util.List<java.lang.Double> values)
Returns aDoubleVal
annotation using the values.CFTransfer
createFlowTransferFunction(CFAbstractAnalysis<CFValue,CFStore,CFTransfer> analysis)
Returns the appropriate transfer function that is used for the given org.checkerframework.dataflow analysis.javax.lang.model.element.AnnotationMirror
createIntRangeAnnotation(Range range)
Create an@IntRange
or@IntVal
annotation from the range.javax.lang.model.element.AnnotationMirror
createIntValAnnotation(@Nullable java.util.List<java.lang.Long> values)
javax.lang.model.element.AnnotationMirror
createMatchesRegexAnnotation(@Nullable java.util.List<@Regex java.lang.String> regexes)
Creates anMatchesRegex
annotation for the given regular expressions.javax.lang.model.element.AnnotationMirror
createNumberAnnotationMirror(@Nullable java.util.List<java.lang.Number> values)
Returns an annotation that represents the given set of values.protected QualifierHierarchy
createQualifierHierarchy()
Returns theQualifierHierarchy
to be used by this checker.javax.lang.model.element.AnnotationMirror
createStringAnnotation(@Nullable java.util.List<java.lang.String> values)
Returns aStringVal
annotation using the values.protected java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>>
createSupportedTypeQualifiers()
Returns a mutable set of annotation classes that are supported by a checker.protected TreeAnnotator
createTreeAnnotator()
Returns aTreeAnnotator
that adds annotations to a type based on the contents of a tree.protected TypeAnnotator
createTypeAnnotator()
Returns aDefaultForTypeAnnotator
that adds annotations to a type based on the content of the type itself.protected TypeHierarchy
createTypeHierarchy()
Creates the type hierarchy to be used by this factory.@PolyNull java.util.List<java.lang.Integer>
getArrayLength(@PolyNull javax.lang.model.element.AnnotationMirror arrayAnno)
Returns the set of possible array lengths as a sorted list with no duplicate values.protected int
getArrayLenRangeFromValue(javax.lang.model.element.AnnotationMirror anno)
Gets the from() element/field out of an ArrayLenRange annotation.protected int
getArrayLenRangeToValue(javax.lang.model.element.AnnotationMirror anno)
Gets the to() element/field out of an ArrayLenRange annotation.@Nullable java.lang.Boolean
getBooleanValue(@Nullable javax.lang.model.element.AnnotationMirror boolAnno)
Returns the single possible boolean value, or null if there is not exactly one possible value.@Nullable java.util.List<java.lang.Boolean>
getBooleanValues(@Nullable javax.lang.model.element.AnnotationMirror boolAnno)
Returns the set of possible boolean values as a sorted list with no duplicate values.@PolyNull java.util.List<java.lang.Character>
getCharValues(@PolyNull javax.lang.model.element.AnnotationMirror intAnno)
Returns the set of possible values as a sorted list with no duplicate values.@PolyNull java.util.List<java.lang.String>
getDoesNotMatchRegexValues(@PolyNull javax.lang.model.element.AnnotationMirror doesNotMatchRegexAnno)
Returns the set of possible regexes as a sorted list with no duplicate values.@PolyNull java.util.List<java.lang.Double>
getDoubleValues(@PolyNull javax.lang.model.element.AnnotationMirror doubleAnno)
Returns the set of possible values as a sorted list with no duplicate values.@Nullable AnnotatedTypeMirror
getDummyAssignedTo(com.sun.source.tree.ExpressionTree expressionTree)
Returns the annotation type mirror for the type ofexpressionTree
with default annotations applied.protected java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>>
getFieldInvariantDeclarationAnnotations()
Returns the set of classes of field invariant annotations.@Nullable FieldInvariants
getFieldInvariants(javax.lang.model.element.TypeElement element)
Returns the field invariants for the given class, as expressed by the user in@FieldInvariant
method annotations.long
getFromValueFromIntRange(AnnotatedTypeMirror atm)
Finds the appropriate value for thefrom
value of an annotated type mirror containing anIntRange
annotation.protected long
getIntRangeFromValue(javax.lang.model.element.AnnotationMirror intRangeAnno)
Gets the from() element/field out of an IntRange annotation.protected long
getIntRangeFromValue(javax.lang.model.element.AnnotationMirror intRangeAnno, long defaultValue)
Gets the from() element/field out of an IntRange annotation.protected long
getIntRangeToValue(javax.lang.model.element.AnnotationMirror intRangeAnno)
Gets the to() element/field out of an IntRange annotation.protected long
getIntRangeToValue(javax.lang.model.element.AnnotationMirror intRangeAnno, long defaultValue)
Gets the to() element/field out of an IntRange annotation.@PolyNull java.util.List<java.lang.Long>
getIntValues(@PolyNull javax.lang.model.element.AnnotationMirror intAnno)
Returns the set of possible values as a sorted list with no duplicate values.@PolyNull java.util.List<java.lang.String>
getMatchesRegexValues(@PolyNull javax.lang.model.element.AnnotationMirror matchesRegexAnno)
Returns the set of possible regexes as a sorted list with no duplicate values.@Nullable java.lang.Integer
getMaxLenValue(@Nullable javax.lang.model.element.AnnotationMirror annotation)
Used to find the maximum length of an array.@Nullable java.lang.Long
getMinimumIntegralValue(AnnotatedTypeMirror atm)
Returns the smallest possible value that an integral annotation might take on.int
getMinLenFromString(java.lang.String sequenceExpression, com.sun.source.tree.Tree tree, com.sun.source.util.TreePath currentPath)
Returns the minimum length of an array expression or 0 if the min length is unknown.int
getMinLenValue(@Nullable javax.lang.model.element.AnnotationMirror annotation)
Used to find the minimum length of an array, which is useful for array bounds checking.int
getMinLenValue(AnnotatedTypeMirror atm)
int
getMinLenValue(AnnotationMirrorSet annotations)
Returns the minimum length of an array.protected int
getMinLenValueValue(javax.lang.model.element.AnnotationMirror anno)
Gets the value() element/field out of a MinLen annotation.@Nullable Range
getRange(@Nullable javax.lang.model.element.AnnotationMirror rangeAnno)
Returns aRange
bounded by the values specified in the given@Range
annotation.@PolyNull java.util.List<java.lang.String>
getStringValues(@PolyNull javax.lang.model.element.AnnotationMirror stringAnno)
Returns the set of possible values as a sorted list with no duplicate values.long
getToValueFromIntRange(AnnotatedTypeMirror atm)
Finds the appropriate value for theto
value of an annotated type mirror containing anIntRange
annotation.AnnotationMirrorSet
getWidenedAnnotations(AnnotationMirrorSet annos, javax.lang.model.type.TypeKind typeKind, javax.lang.model.type.TypeKind widenedTypeKind)
Returns annotations applicable to typewidenedTypeKind
, that are copied or adapted fromannos
.boolean
isImmutable(javax.lang.model.type.TypeMirror type)
A fact about an array, such as its length, cannot be changed via side effects to the array.boolean
isIntRange(javax.lang.model.element.AnnotationMirror anno)
Returns true ifanno
is anIntRange
,IntRangeFromPositive
,IntRangeFromNonNegative
, orIntRangeFromGTENegativeOne
.boolean
isIntRange(AnnotationMirrorSet anmSet)
Returns true ifisIntRange(AnnotationMirror)
returns true for any annotation in the given set.AnnotatedTypeFactory.ParameterizedExecutableType
methodFromUse(com.sun.source.tree.ExpressionTree tree, javax.lang.model.element.ExecutableElement methodElt, AnnotatedTypeMirror receiverType)
Creates array length annotations for the result of the Enum.values() method, which is the number of possible values of the enum.-
Methods inherited from class org.checkerframework.common.basetype.BaseAnnotatedTypeFactory
createFlowAnalysis
-
Methods inherited from class org.checkerframework.framework.type.GenericAnnotatedTypeFactory
addAnnotationsFromDefaultForType, addCheckedCodeDefaults, addCheckedStandardDefaults, addComputedTypeAnnotations, addComputedTypeAnnotations, addComputedTypeAnnotations, addDefaultAnnotations, addSharedCFGForTree, addUncheckedStandardDefaults, analyze, annotationsForIrrelevantJavaType, applyQualifierParameterDefaults, applyQualifierParameterDefaults, checkAndPerformFlowAnalysis, checkForDefaultQualifierInHierarchy, constructorFromUse, constructorFromUsePreSubstitution, createAndInitQualifierDefaults, createCFGVisualizer, createContractsFromMethod, createDefaultForTypeAnnotator, createDefaultForUseTypeAnnotator, createDependentTypesHelper, createQualifierDefaults, createQualifierPolymorphism, createRequiresOrEnsuresQualifier, getAnnotatedTypeBefore, getAnnotatedTypeLhs, getAnnotatedTypeLhsNoTypeVarDefault, getAnnotatedTypeRhsUnaryAssign, getAnnotatedTypeVarargsArray, getAnnotationFromJavaExpression, getAnnotationFromJavaExpressionString, getAnnotationMirrorFromJavaExpressionString, getAnnotationsFromJavaExpression, getCFGVisualizer, getContractExpressions, getContractsFromMethod, getDefaultAnnotations, getDefaultForTypeAnnotator, getDefaultValueAnnotatedType, getDependentTypesHelper, getEmptyStore, getEnsuresQualifierIfResult, getExceptionalExitStore, getExplicitNewClassAnnos, getExplicitNewClassClassTypeArgs, getExpressionAndOffsetFromJavaExpressionString, getFinalLocalValues, getFirstNodeOfKindForTree, getInferredValueFor, getMethodReturnType, getNodesForTree, getQualifierPolymorphism, getRegularExitStore, getResultingTypeOfConstructorMemberReference, getReturnStatementStores, getSharedCFGForTree, getShouldDefaultTypeVarLocals, getSortedQualifierNames, getStoreAfter, getStoreAfter, getStoreAfter, getStoreBefore, getStoreBefore, getStoreBefore, getSupportedMonotonicTypeQualifiers, getTypeFactoryOfSubchecker, getTypeFactoryOfSubcheckerOrNull, handleCFGViz, irrelevantExtraMessage, isComputingAnnotatedTypeMirrorOfLhs, isNotFullyInitializedReceiver, 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, addAliasedDeclAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAnnotationFromFieldInvariant, addInheritedAnnotation, applyCaptureConversion, applyCaptureConversion, applyUnboxing, areSameByClass, binaryTreeArgTypes, binaryTreeArgTypes, binaryTreeArgTypes, compoundAssignmentTreeArgTypes, containsSameByClass, containsUninferredTypeArguments, createAnnotatedTypeFormatter, createAnnotationClassLoader, createAnnotationFormatter, createQualifierUpperBounds, createTypeArgumentInference, createTypeVariableSubstitutor, createViewpointAdapter, declarationFromElement, doesAnnotatedForApplyToThisChecker, fromElement, fromElement, fromElement, fromNewClass, getAnnotatedNullType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedTypeFormatter, getAnnotatedTypeFromTypeTree, getAnnotationByClass, getAnnotationFormatter, getAnnotationMirror, getAnnotationOrTypeDeclarationBound, getAnnotationWithMetaAnnotation, getBoxedType, getBundledTypeQualifiers, getCacheSize, getChecker, getCheckerNames, getContractExpressions, getContractListValues, getCurrentClassTree, getCurrentMethodReceiver, getDeclAnnotation, getDeclAnnotationNoAliases, getDeclAnnotations, getDeclAnnotationWithMetaAnnotation, getDefaultTypeDeclarationBounds, getElementUtils, getEnclosingClassOrMethod, getEnclosingSubType, getEnclosingType, getEnumConstructorQualifiers, getExpressionAndOffset, getFieldInvariantAnnotationTree, 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, getWidenedType, getWidenedType, hasExplicitNoQualifierParameterInHierarchy, hasExplicitQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, initializeReflectionResolution, isFromByteCode, isFromStubFile, isSideEffectFree, isSupportedQualifier, isSupportedQualifier, isSupportedQualifier, isWithinConstructor, mergeAnnotationFileAnnosIntoType, negateConstant, order, parseAnnotationFiles, postProcessClassTree, replaceAnnotations, replaceAnnotations, setPathForArtificialTree, setVisitorTreePath, shouldWarnIfStubRedundantWithBytecode, toAnnotatedType, toString, type
-
-
-
-
Field Detail
-
UNKNOWN_NAME
public static final java.lang.String UNKNOWN_NAME
Fully-qualified class name ofUnknownVal
.- See Also:
- Constant Field Values
-
BOTTOMVAL_NAME
public static final java.lang.String BOTTOMVAL_NAME
Fully-qualified class name ofBottomVal
.- See Also:
- Constant Field Values
-
POLY_NAME
public static final java.lang.String POLY_NAME
Fully-qualified class name ofPolyValue
.- See Also:
- Constant Field Values
-
ARRAYLEN_NAME
public static final java.lang.String ARRAYLEN_NAME
Fully-qualified class name ofArrayLen
.- See Also:
- Constant Field Values
-
BOOLVAL_NAME
public static final java.lang.String BOOLVAL_NAME
Fully-qualified class name ofBoolVal
.- See Also:
- Constant Field Values
-
DOUBLEVAL_NAME
public static final java.lang.String DOUBLEVAL_NAME
Fully-qualified class name ofDoubleVal
.- See Also:
- Constant Field Values
-
INTVAL_NAME
public static final java.lang.String INTVAL_NAME
Fully-qualified class name ofIntVal
.- See Also:
- Constant Field Values
-
STRINGVAL_NAME
public static final java.lang.String STRINGVAL_NAME
Fully-qualified class name ofStringVal
.- See Also:
- Constant Field Values
-
ARRAYLENRANGE_NAME
public static final java.lang.String ARRAYLENRANGE_NAME
Fully-qualified class name ofArrayLenRange
.- See Also:
- Constant Field Values
-
INTRANGE_NAME
public static final java.lang.String INTRANGE_NAME
Fully-qualified class name ofIntRange
.- See Also:
- Constant Field Values
-
INTRANGE_FROMGTENEGONE_NAME
public static final java.lang.String INTRANGE_FROMGTENEGONE_NAME
Fully-qualified class name ofIntRangeFromGTENegativeOne
.- See Also:
- Constant Field Values
-
INTRANGE_FROMNONNEG_NAME
public static final java.lang.String INTRANGE_FROMNONNEG_NAME
Fully-qualified class name ofIntRangeFromNonNegative
.- See Also:
- Constant Field Values
-
INTRANGE_FROMPOS_NAME
public static final java.lang.String INTRANGE_FROMPOS_NAME
Fully-qualified class name ofIntRangeFromPositive
.- See Also:
- Constant Field Values
-
MINLEN_NAME
public static final java.lang.String MINLEN_NAME
Fully-qualified class name ofMinLen
.- See Also:
- Constant Field Values
-
MATCHES_REGEX_NAME
public static final java.lang.String MATCHES_REGEX_NAME
Fully-qualified class name ofMatchesRegex
.- See Also:
- Constant Field Values
-
DOES_NOT_MATCH_REGEX_NAME
public static final java.lang.String DOES_NOT_MATCH_REGEX_NAME
Fully-qualified class name ofDoesNotMatchRegex
.- See Also:
- Constant Field Values
-
MAX_VALUES
protected static final int MAX_VALUES
The maximum number of values allowed in an annotation's array.- See Also:
- Constant Field Values
-
UNKNOWNVAL
protected final javax.lang.model.element.AnnotationMirror UNKNOWNVAL
The top type for this hierarchy.
-
BOTTOMVAL
protected final javax.lang.model.element.AnnotationMirror BOTTOMVAL
The bottom type for this hierarchy.
-
POLY
public final javax.lang.model.element.AnnotationMirror POLY
The canonical @PolyValue
annotation.
-
BOOLEAN_TRUE
public final javax.lang.model.element.AnnotationMirror BOOLEAN_TRUE
The canonical @BoolVal
(true) annotation.
-
BOOLEAN_FALSE
public final javax.lang.model.element.AnnotationMirror BOOLEAN_FALSE
The canonical @BoolVal
(false) annotation.
-
arrayLenValueElement
protected final javax.lang.model.element.ExecutableElement arrayLenValueElement
The value() element/field of an @ArrayLen annotation.
-
arrayLenRangeFromElement
protected final javax.lang.model.element.ExecutableElement arrayLenRangeFromElement
The from() element/field of an @ArrayLenRange annotation.
-
arrayLenRangeToElement
protected final javax.lang.model.element.ExecutableElement arrayLenRangeToElement
The to() element/field of an @ArrayLenRange annotation.
-
boolValValueElement
protected final javax.lang.model.element.ExecutableElement boolValValueElement
The value() element/field of a @BoolVal annotation.
-
doubleValValueElement
protected final javax.lang.model.element.ExecutableElement doubleValValueElement
The value() element/field of a @DoubleVal annotation.
-
intRangeFromElement
protected final javax.lang.model.element.ExecutableElement intRangeFromElement
The from() element/field of an @IntRange annotation.
-
intRangeToElement
protected final javax.lang.model.element.ExecutableElement intRangeToElement
The to() element/field of an @IntRange annotation.
-
intValValueElement
protected final javax.lang.model.element.ExecutableElement intValValueElement
The value() element/field of a @IntVal annotation.
-
matchesRegexValueElement
public final javax.lang.model.element.ExecutableElement matchesRegexValueElement
The value() element/field of a @MatchesRegex annotation.
-
doesNotMatchRegexValueElement
public final javax.lang.model.element.ExecutableElement doesNotMatchRegexValueElement
The value() element/field of a @DoesNotMatchRegex annotation.
-
minLenValueElement
protected final javax.lang.model.element.ExecutableElement minLenValueElement
The value() element/field of a @MinLen annotation.
-
minLenFieldInvariantFieldElement
protected final javax.lang.model.element.ExecutableElement minLenFieldInvariantFieldElement
The field() element/field of a @MinLenFieldInvariant annotation.
-
minLenFieldInvariantMinLenElement
protected final javax.lang.model.element.ExecutableElement minLenFieldInvariantMinLenElement
The minLen() element/field of a @MinLenFieldInvariant annotation.
-
stringValValueElement
public final javax.lang.model.element.ExecutableElement stringValValueElement
The value() element/field of a @StringVal annotation.
-
evaluator
protected final ReflectiveEvaluator evaluator
Helper class that evaluates statically executable methods, constructors, and fields.
-
-
Constructor Detail
-
ValueAnnotatedTypeFactory
public ValueAnnotatedTypeFactory(BaseTypeChecker checker)
-
-
Method Detail
-
applyInferredAnnotations
protected void applyInferredAnnotations(AnnotatedTypeMirror type, CFValue inferred)
Description copied from class:GenericAnnotatedTypeFactory
Applies the annotations inferred by the org.checkerframework.dataflow analysis to the typetype
.- Overrides:
applyInferredAnnotations
in classGenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>
- Parameters:
type
- the type to modifyinferred
- the inferred annotations to apply
-
canonicalAnnotation
public javax.lang.model.element.AnnotationMirror canonicalAnnotation(javax.lang.model.element.AnnotationMirror anno)
Description copied from class:AnnotatedTypeFactory
Returns the canonical annotation for the passed annotation. Returns null if the passed annotation is not an alias of a canonical one in the framework.A canonical annotation is the internal annotation that will be used by the Checker Framework in the aliased annotation's place.
- Overrides:
canonicalAnnotation
in classAnnotatedTypeFactory
- Parameters:
anno
- the qualifier to check for an alias- Returns:
- the canonical annotation, or null if none exists
-
createSupportedTypeQualifiers
protected java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>> createSupportedTypeQualifiers()
Description copied from class:AnnotatedTypeFactory
Returns a mutable set of annotation classes that are supported by a checker.Subclasses may override this method to return a mutable 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 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 ofElementType.TYPE_PARAMETER
, but no otherElementType
values) are automatically considered as supported annotations.To support a different set of annotations than those in the qual subdirectory, or that have other
ElementType
values, see examples below.In total, there are 5 ways to indicate annotations that are supported by a checker:
- Only support annotations located in a checker's qual directory:
This is the default behavior. Simply place those annotations within the qual directory.
- Support annotations located in a checker's qual directory and a list of
other annotations:
Place those annotations within the qual directory, and override
AnnotatedTypeFactory.createSupportedTypeQualifiers()
by callingAnnotatedTypeFactory.getBundledTypeQualifiers(Class...)
with a varargs parameter list of the other annotations. Code example:@Override protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers() { return getBundledTypeQualifiers(Regex.class, PartialRegex.class, RegexBottom.class, UnknownRegex.class); }
- Supporting only annotations that are explicitly listed: Override
AnnotatedTypeFactory.createSupportedTypeQualifiers()
and return a mutable set of the supported annotations. Code example:@Override protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers() { return new HashSet<Class<? extends Annotation>>( Arrays.asList(A.class, B.class)); }
AnnotatedTypeFactory.createSupportedTypeQualifiers()
must be a fresh, mutable set. The methodsAnnotatedTypeFactory.getBundledTypeQualifiers(Class...)
must return a fresh, mutable set
- Overrides:
createSupportedTypeQualifiers
in classAnnotatedTypeFactory
- Returns:
- the type qualifiers supported this processor, or an empty set if none
- Only support annotations located in a checker's qual directory:
-
createFlowTransferFunction
public CFTransfer createFlowTransferFunction(CFAbstractAnalysis<CFValue,CFStore,CFTransfer> analysis)
Description copied from class:GenericAnnotatedTypeFactory
Returns the appropriate transfer function that is used for the given org.checkerframework.dataflow analysis.This implementation uses the checker naming convention to create the appropriate transfer function. If no transfer function is found, it returns an instance of
CFTransfer
.Subclasses have to override this method to create the appropriate transfer function if they do not follow the checker naming convention.
- Overrides:
createFlowTransferFunction
in classGenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>
- Parameters:
analysis
- a dataflow analysis- Returns:
- a new transfer function
-
createQualifierHierarchy
protected QualifierHierarchy createQualifierHierarchy()
Description copied from class:AnnotatedTypeFactory
Returns theQualifierHierarchy
to be used by this checker.The implementation builds the type qualifier hierarchy for the
AnnotatedTypeFactory.getSupportedTypeQualifiers()
using the meta-annotations found in them. The current implementation returns an instance ofNoElementQualifierHierarchy
.Subclasses must override this method if their qualifiers have elements; the method must return an implementation of
QualifierHierarchy
, such asElementQualifierHierarchy
.- Overrides:
createQualifierHierarchy
in classAnnotatedTypeFactory
- Returns:
- a QualifierHierarchy for this type system
-
createTypeHierarchy
protected TypeHierarchy createTypeHierarchy()
Description copied from class:AnnotatedTypeFactory
Creates the type hierarchy to be used by this factory.Subclasses may override this method to specify new type-checking rules beyond the typical Java subtyping rules.
- Overrides:
createTypeHierarchy
in classAnnotatedTypeFactory
- Returns:
- the type relations class to check type subtyping
-
createTypeAnnotator
protected TypeAnnotator 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<CFValue,CFStore,CFTransfer,CFAnalysis>
- Returns:
- a type annotator
-
getFieldInvariants
public @Nullable FieldInvariants getFieldInvariants(javax.lang.model.element.TypeElement element)
Description copied from class:AnnotatedTypeFactory
Returns the field invariants for the given class, as expressed by the user in@FieldInvariant
method annotations.Subclasses may implement their own field invariant annotations if
@FieldInvariant
is not expressive enough. They must override this method to properly create AnnotationMirror and also overrideAnnotatedTypeFactory.getFieldInvariantDeclarationAnnotations()
to return their field invariants.- Overrides:
getFieldInvariants
in classAnnotatedTypeFactory
- Parameters:
element
- class for which to get invariants- Returns:
- field invariants for
element
-
getFieldInvariantDeclarationAnnotations
protected java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>> getFieldInvariantDeclarationAnnotations()
Description copied from class:AnnotatedTypeFactory
Returns the set of classes of field invariant annotations.- Overrides:
getFieldInvariantDeclarationAnnotations
in classAnnotatedTypeFactory
- Returns:
- the set of classes of field invariant annotations
-
methodFromUse
public AnnotatedTypeFactory.ParameterizedExecutableType methodFromUse(com.sun.source.tree.ExpressionTree tree, javax.lang.model.element.ExecutableElement methodElt, AnnotatedTypeMirror receiverType)
Creates array length annotations for the result of the Enum.values() method, which is the number of possible values of the enum.- Overrides:
methodFromUse
in classAnnotatedTypeFactory
- Parameters:
tree
- either a MethodInvocationTree or a MemberReferenceTreemethodElt
- the element of the referenced methodreceiverType
- the type of the receiver- Returns:
- the method type being invoked with tree and the (inferred) type arguments
- See Also:
AnnotatedTypeFactory.methodFromUse(MethodInvocationTree)
-
getWidenedAnnotations
public AnnotationMirrorSet getWidenedAnnotations(AnnotationMirrorSet annos, javax.lang.model.type.TypeKind typeKind, javax.lang.model.type.TypeKind widenedTypeKind)
Description copied from class:AnnotatedTypeFactory
Returns annotations applicable to typewidenedTypeKind
, that are copied or adapted fromannos
.- Overrides:
getWidenedAnnotations
in classAnnotatedTypeFactory
- Parameters:
annos
- annotations to widen, from a primitive or boxed primitivetypeKind
- primitive type to widenwidenedTypeKind
- target for the returned annotations; a primitive type that is wider thantypeKind
(in the sense of JLS 5.1.2)- Returns:
- result of converting
annos
fromtypeKind
towidenedTypeKind
-
getFromValueFromIntRange
public long getFromValueFromIntRange(AnnotatedTypeMirror atm)
Finds the appropriate value for thefrom
value of an annotated type mirror containing anIntRange
annotation.- Parameters:
atm
- an annotated type mirror that contains anIntRange
annotation- Returns:
- either the from value from the passed int range annotation, or the minimum value of the domain of the underlying type (i.e. Integer.MIN_VALUE if the underlying type is int)
-
getToValueFromIntRange
public long getToValueFromIntRange(AnnotatedTypeMirror atm)
Finds the appropriate value for theto
value of an annotated type mirror containing anIntRange
annotation.- Parameters:
atm
- an annotated type mirror that contains anIntRange
annotation- Returns:
- either the to value from the passed int range annotation, or the maximum value of the domain of the underlying type (i.e. Integer.MAX_VALUE if the underlying type is int)
-
getIntRangeFromValue
protected long getIntRangeFromValue(javax.lang.model.element.AnnotationMirror intRangeAnno)
Gets the from() element/field out of an IntRange annotation. The from() element/field must exist. Clients should callgetFromValueFromIntRange(org.checkerframework.framework.type.AnnotatedTypeMirror)
if it might not exist.- Parameters:
intRangeAnno
- an IntRange annotation- Returns:
- its from() element/field
-
getIntRangeFromValue
protected long getIntRangeFromValue(javax.lang.model.element.AnnotationMirror intRangeAnno, long defaultValue)
Gets the from() element/field out of an IntRange annotation. The from() element/field must exist. Clients should callgetFromValueFromIntRange(org.checkerframework.framework.type.AnnotatedTypeMirror)
if it might not exist.- Parameters:
intRangeAnno
- an IntRange annotationdefaultValue
- the value to return if there is no from() element/field- Returns:
- its from() element/field
-
getIntRangeToValue
protected long getIntRangeToValue(javax.lang.model.element.AnnotationMirror intRangeAnno, long defaultValue)
Gets the to() element/field out of an IntRange annotation. The to() element/field must exist. Clients should callgetToValueFromIntRange(org.checkerframework.framework.type.AnnotatedTypeMirror)
if it might not exist.- Parameters:
intRangeAnno
- an IntRange annotationdefaultValue
- the value to retur if there is no to() element/field- Returns:
- its to() element/field
-
getIntRangeToValue
protected long getIntRangeToValue(javax.lang.model.element.AnnotationMirror intRangeAnno)
Gets the to() element/field out of an IntRange annotation. The to() element/field must exist. Clients should callgetToValueFromIntRange(org.checkerframework.framework.type.AnnotatedTypeMirror)
if it might not exist.- Parameters:
intRangeAnno
- an IntRange annotation- Returns:
- its to() element/field
-
getArrayLenRangeFromValue
protected int getArrayLenRangeFromValue(javax.lang.model.element.AnnotationMirror anno)
Gets the from() element/field out of an ArrayLenRange annotation.- Parameters:
anno
- an ArrayLenRange annotation- Returns:
- its from() element/field
-
getArrayLenRangeToValue
protected int getArrayLenRangeToValue(javax.lang.model.element.AnnotationMirror anno)
Gets the to() element/field out of an ArrayLenRange annotation.- Parameters:
anno
- an ArrayLenRange annotation- Returns:
- its to() element/field
-
getMinLenValueValue
protected int getMinLenValueValue(javax.lang.model.element.AnnotationMirror anno)
Gets the value() element/field out of a MinLen annotation.- Parameters:
anno
- a MinLen annotation- Returns:
- its value() element/field
-
createTreeAnnotator
protected TreeAnnotator 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 classGenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>
- Returns:
- a tree annotator
-
createIntValAnnotation
public javax.lang.model.element.AnnotationMirror createIntValAnnotation(@Nullable java.util.List<java.lang.Long> values)
Returns aIntVal
orIntRange
annotation using the values. Ifvalues
is null, then UnknownVal is returned; ifvalues
is empty, then bottom is returned. If the number ofvalues
is greater than MAX_VALUES, return anIntRange
. In other cases, the values are sorted and duplicates are removed before anIntVal
is created.- Parameters:
values
- list of longs; duplicates are allowed and the values may be in any order- Returns:
- an annotation depends on the values
-
convertIntRangeToIntVal
public javax.lang.model.element.AnnotationMirror convertIntRangeToIntVal(javax.lang.model.element.AnnotationMirror intRangeAnno)
Convert an@IntRange
annotation to an@IntVal
annotation, or to UNKNOWNVAL if the input is too wide to be represented as an@IntVal
.- Parameters:
intRangeAnno
- an@IntRange
annotation- Returns:
- an
@IntVal
annotation corresponding to the argument
-
createDoubleValAnnotation
public javax.lang.model.element.AnnotationMirror createDoubleValAnnotation(@Nullable java.util.List<java.lang.Double> values)
Returns aDoubleVal
annotation using the values. Ifvalues
is null, then UnknownVal is returned; ifvalues
is empty, then bottom is returned. The values are sorted and duplicates are removed before the annotation is created.- Parameters:
values
- list of doubles; duplicates are allowed and the values may be in any order- Returns:
- a
DoubleVal
annotation using the values
-
createStringAnnotation
public javax.lang.model.element.AnnotationMirror createStringAnnotation(@Nullable java.util.List<java.lang.String> values)
Returns aStringVal
annotation using the values. Ifvalues
is null, then UnknownVal is returned; ifvalues
is empty, then bottom is returned. The values are sorted and duplicates are removed before the annotation is created. If values is larger than the max number of values allowed (10 by default), then anArrayLen
or anArrayLenRange
annotation is returned.- Parameters:
values
- list of strings; duplicates are allowed and the values may be in any order- Returns:
- a
StringVal
annotation using the values
-
createArrayLenAnnotation
public javax.lang.model.element.AnnotationMirror createArrayLenAnnotation(@Nullable java.util.List<java.lang.Integer> values)
Returns aArrayLen
annotation using the values. Ifvalues
is null, then UnknownVal is returned; ifvalues
is empty, then bottom is returned. The values are sorted and duplicates are removed before the annotation is created. If values is larger than the max number of values allowed (10 by default), then anArrayLenRange
annotation is returned.- Parameters:
values
- list of integers; duplicates are allowed and the values may be in any order- Returns:
- a
ArrayLen
annotation using the values
-
createBooleanAnnotation
public javax.lang.model.element.AnnotationMirror createBooleanAnnotation(@Nullable java.util.List<java.lang.Boolean> values)
Returns aBoolVal
annotation using the values. Ifvalues
is null, then UnknownVal is returned; ifvalues
is empty, then bottom is returned. The values are sorted and duplicates are removed before the annotation is created.- Parameters:
values
- list of booleans; duplicates are allowed and the values may be in any order- Returns:
- a
BoolVal
annotation using the values
-
createCharAnnotation
public javax.lang.model.element.AnnotationMirror createCharAnnotation(@Nullable java.util.List<java.lang.Character> values)
Returns aIntVal
annotation using the values. Ifvalues
is null, then UnknownVal is returned; ifvalues
is empty, then bottom is returned. The values are sorted and duplicates are removed before the annotation is created.- Parameters:
values
- list of characters; duplicates are allowed and the values may be in any order- Returns:
- a
IntVal
annotation using the values
-
createDoubleAnnotation
public javax.lang.model.element.AnnotationMirror createDoubleAnnotation(@Nullable java.util.List<java.lang.Double> values)
Returns aDoubleVal
annotation using the values. Ifvalues
is null, then UnknownVal is returned; ifvalues
is empty, then bottom is returned. The values are sorted and duplicates are removed before the annotation is created.- Parameters:
values
- list of doubleacters; duplicates are allowed and the values may be in any order- Returns:
- a
IntVal
annotation using the values
-
createNumberAnnotationMirror
public javax.lang.model.element.AnnotationMirror createNumberAnnotationMirror(@Nullable java.util.List<java.lang.Number> values)
Returns an annotation that represents the given set of values.- Parameters:
values
- a homogeneous list: every element of it has the same class. This method does not modify or store it.- Returns:
- an annotation that represents the given set of values
-
createIntRangeAnnotation
public javax.lang.model.element.AnnotationMirror createIntRangeAnnotation(Range range)
Create an@IntRange
or@IntVal
annotation from the range. May return BOTTOMVAL or UNKNOWNVAL.
-
createArrayLenRangeAnnotation
public javax.lang.model.element.AnnotationMirror createArrayLenRangeAnnotation(int from, int to)
Create an@ArrayLenRange
annotation from the two (inclusive) bounds. Does not return BOTTOMVAL or UNKNOWNVAL.
-
createArrayLenRangeAnnotation
public javax.lang.model.element.AnnotationMirror createArrayLenRangeAnnotation(Range range)
Create an@ArrayLenRange
annotation from the range. May return BOTTOMVAL or UNKNOWNVAL.
-
createMatchesRegexAnnotation
public javax.lang.model.element.AnnotationMirror createMatchesRegexAnnotation(@Nullable java.util.List<@Regex java.lang.String> regexes)
Creates anMatchesRegex
annotation for the given regular expressions.- Parameters:
regexes
- a list of Java regular expressions- Returns:
- a MatchesRegex annotation with those values
-
createDoesNotMatchRegexAnnotation
public javax.lang.model.element.AnnotationMirror createDoesNotMatchRegexAnnotation(@Nullable java.util.List<@Regex java.lang.String> regexes)
Creates anDoesNotMatchRegex
annotation for the given regular expressions.- Parameters:
regexes
- a list of Java regular expressions- Returns:
- a DoesNotMatchRegex annotation with those values
-
convertArrayLenToArrayLenRange
public javax.lang.model.element.AnnotationMirror convertArrayLenToArrayLenRange(javax.lang.model.element.AnnotationMirror arrayLenAnno)
Converts an@ArrayLen
annotation to an@ArrayLenRange
annotation.- Parameters:
arrayLenAnno
- an ArrayLen annotation- Returns:
- an ArrayLenRange annotation representing the bounds of the given ArrayLen annotation
-
convertIntValToIntRange
public javax.lang.model.element.AnnotationMirror convertIntValToIntRange(javax.lang.model.element.AnnotationMirror intValAnno)
Converts an@IntVal
annotation to an@IntRange
annotation.
-
getRange
public @Nullable Range getRange(@Nullable javax.lang.model.element.AnnotationMirror rangeAnno)
Returns aRange
bounded by the values specified in the given@Range
annotation. Also returns an appropriate range if an@IntVal
annotation is passed. Returnsnull
if the annotation is null or if the annotation is not anIntRange
,IntRangeFromPositive
,IntVal
, orArrayLenRange
.- Parameters:
rangeAnno
- a@Range
annotation- Returns:
- the
Range
that the annotation represents
-
getIntValues
public @PolyNull java.util.List<java.lang.Long> getIntValues(@PolyNull javax.lang.model.element.AnnotationMirror intAnno)
Returns the set of possible values as a sorted list with no duplicate values. Returns the empty list if no values are possible (for dead code). Returns null if any value is possible -- that is, if no estimate can be made -- and this includes when there is no constant-value annotation so the argument is null.The method returns a list of
Long
but is namedgetIntValues
because it supports the@IntVal
annotation.- Parameters:
intAnno
- an@IntVal
annotation, or null- Returns:
- the possible values, deduplicated and sorted
-
getDoubleValues
public @PolyNull java.util.List<java.lang.Double> getDoubleValues(@PolyNull javax.lang.model.element.AnnotationMirror doubleAnno)
Returns the set of possible values as a sorted list with no duplicate values. Returns the empty list if no values are possible (for dead code). Returns null if any value is possible -- that is, if no estimate can be made -- and this includes when there is no constant-value annotation so the argument is null.- Parameters:
doubleAnno
- a@DoubleVal
annotation, or null- Returns:
- the possible values, deduplicated and sorted
-
getArrayLength
public @PolyNull java.util.List<java.lang.Integer> getArrayLength(@PolyNull javax.lang.model.element.AnnotationMirror arrayAnno)
Returns the set of possible array lengths as a sorted list with no duplicate values. Returns the empty list if no values are possible (for dead code). Returns null if any value is possible -- that is, if no estimate can be made -- and this includes when there is no constant-value annotation so the argument is null.- Parameters:
arrayAnno
- an@ArrayLen
annotation, or null- Returns:
- the possible array lengths, deduplicated and sorted
-
getCharValues
public @PolyNull java.util.List<java.lang.Character> getCharValues(@PolyNull javax.lang.model.element.AnnotationMirror intAnno)
Returns the set of possible values as a sorted list with no duplicate values. Returns the empty list if no values are possible (for dead code). Returns null if any value is possible -- that is, if no estimate can be made -- and this includes when there is no constant-value annotation so the argument is null.- Parameters:
intAnno
- an@IntVal
annotation, or null- Returns:
- the values represented by the given
@IntVal
annotation
-
getBooleanValue
public @Nullable java.lang.Boolean getBooleanValue(@Nullable javax.lang.model.element.AnnotationMirror boolAnno)
Returns the single possible boolean value, or null if there is not exactly one possible value.- Parameters:
boolAnno
- a@BoolVal
annotation, or null- Returns:
- the single possible boolean value, on null if that is not the case
- See Also:
getBooleanValues(javax.lang.model.element.AnnotationMirror)
-
getBooleanValues
public @Nullable java.util.List<java.lang.Boolean> getBooleanValues(@Nullable javax.lang.model.element.AnnotationMirror boolAnno)
Returns the set of possible boolean values as a sorted list with no duplicate values. Returns the empty list if no values are possible (for dead code). Returns null if any value is possible -- that is, if no estimate can be made -- and this includes when there is no constant-value annotation so the argument is null.- Parameters:
boolAnno
- a@BoolVal
annotation, or null- Returns:
- a singleton or empty list of possible boolean values, or null
-
getStringValues
public @PolyNull java.util.List<java.lang.String> getStringValues(@PolyNull javax.lang.model.element.AnnotationMirror stringAnno)
Returns the set of possible values as a sorted list with no duplicate values. Returns the empty list if no values are possible (for dead code). Returns null if any value is possible -- that is, if no estimate can be made -- and this includes when there is no constant-value annotation so the argument is null.- Parameters:
stringAnno
- a@StringVal
annotation, or null- Returns:
- the possible values, deduplicated and sorted
-
getMatchesRegexValues
public @PolyNull java.util.List<java.lang.String> getMatchesRegexValues(@PolyNull javax.lang.model.element.AnnotationMirror matchesRegexAnno)
Returns the set of possible regexes as a sorted list with no duplicate values. Returns the empty list if no values are possible (for dead code). Returns null if any value is possible -- that is, if no estimate can be made -- and this includes when there is no @MatchesRegex annotation so the argument is null.- Parameters:
matchesRegexAnno
- a@MatchesRegex
annotation, or null- Returns:
- the possible values, deduplicated and sorted
-
getDoesNotMatchRegexValues
public @PolyNull java.util.List<java.lang.String> getDoesNotMatchRegexValues(@PolyNull javax.lang.model.element.AnnotationMirror doesNotMatchRegexAnno)
Returns the set of possible regexes as a sorted list with no duplicate values. Returns the empty list if no values are possible (for dead code). Returns null if any value is possible -- that is, if no estimate can be made -- and this includes when there is no @DoesNotMatchRegex annotation so the argument is null.- Parameters:
doesNotMatchRegexAnno
- a@DoesNotMatchRegex
annotation, or null- Returns:
- the possible values, deduplicated and sorted
-
isIntRange
public boolean isIntRange(AnnotationMirrorSet anmSet)
Returns true ifisIntRange(AnnotationMirror)
returns true for any annotation in the given set.- Parameters:
anmSet
- a set of annotations- Returns:
- true if any annotation is
IntRange
or related
-
isIntRange
public boolean isIntRange(javax.lang.model.element.AnnotationMirror anno)
Returns true ifanno
is anIntRange
,IntRangeFromPositive
,IntRangeFromNonNegative
, orIntRangeFromGTENegativeOne
.- Parameters:
anno
- annotation mirror- Returns:
- true if
anno
is anIntRange
,IntRangeFromPositive
,IntRangeFromNonNegative
, orIntRangeFromGTENegativeOne
-
getMinLenValue
public int getMinLenValue(AnnotatedTypeMirror atm)
-
getMaxLenValue
public @Nullable java.lang.Integer getMaxLenValue(@Nullable javax.lang.model.element.AnnotationMirror annotation)
Used to find the maximum length of an array. Returns null if there is no minimum length known, or if the passed annotation is null.
-
getMinLenValue
public int getMinLenValue(@Nullable javax.lang.model.element.AnnotationMirror annotation)
Used to find the minimum length of an array, which is useful for array bounds checking. Returns 0 if there is no minimum length known, or if the passed annotation is null.Note that this routine handles actual
MinLen
annotations, because it is called bycanonicalAnnotation(AnnotationMirror)
, which transformsMinLen
annotations intoArrayLenRange
annotations.
-
getMinLenValue
public int getMinLenValue(AnnotationMirrorSet annotations)
Returns the minimum length of an array.- Parameters:
annotations
- the annotations on the array expression- Returns:
- the minimum length of an array
-
getMinimumIntegralValue
public @Nullable java.lang.Long getMinimumIntegralValue(AnnotatedTypeMirror atm)
Returns the smallest possible value that an integral annotation might take on. The passedAnnotatedTypeMirror
should contain either an@IntRange
annotation or an@IntVal
annotation. Returns null if it does not.- Parameters:
atm
- annotated type- Returns:
- the smallest possible integral for which the
atm
could be the type
-
getMinLenFromString
public int getMinLenFromString(java.lang.String sequenceExpression, com.sun.source.tree.Tree tree, com.sun.source.util.TreePath currentPath)
Returns the minimum length of an array expression or 0 if the min length is unknown.- Parameters:
sequenceExpression
- a Java expressiontree
- expression tree or variable declarationcurrentPath
- path to local scope- Returns:
- min length of sequenceExpression or 0
-
getDummyAssignedTo
public @Nullable AnnotatedTypeMirror getDummyAssignedTo(com.sun.source.tree.ExpressionTree expressionTree)
Returns the annotation type mirror for the type ofexpressionTree
with default annotations applied.- 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
-
isImmutable
public boolean isImmutable(javax.lang.model.type.TypeMirror type)
A fact about an array, such as its length, cannot be changed via side effects to the array.- Overrides:
isImmutable
in classAnnotatedTypeFactory
- Parameters:
type
- type to test- Returns:
- true if the type is immutable
-
-