Class LessThanAnnotatedTypeFactory
- java.lang.Object
-
- org.checkerframework.framework.type.AnnotatedTypeFactory
-
- org.checkerframework.framework.type.GenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>
-
- org.checkerframework.common.basetype.BaseAnnotatedTypeFactory
-
- org.checkerframework.checker.index.BaseAnnotatedTypeFactoryForIndexChecker
-
- org.checkerframework.checker.index.inequality.LessThanAnnotatedTypeFactory
-
- All Implemented Interfaces:
AnnotationProvider
public class LessThanAnnotatedTypeFactory extends BaseAnnotatedTypeFactoryForIndexChecker
The type factory for the Less Than Checker.
-
-
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 javax.lang.model.element.AnnotationMirror
LESS_THAN_UNKNOWN
The @LessThanUnknown annotation.-
Fields inherited from class org.checkerframework.checker.index.BaseAnnotatedTypeFactoryForIndexChecker
hasSubsequenceFromElement, hasSubsequenceSubsequenceElement, hasSubsequenceToElement
-
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 LessThanAnnotatedTypeFactory(BaseTypeChecker checker)
Creates a new LessThanAnnotatedTypeFactory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected DependentTypesHelper
createDependentTypesHelper()
Creates aDependentTypesHelper
and returns it.javax.lang.model.element.AnnotationMirror
createLessThanQualifier(@Nullable java.util.List<java.lang.String> expressions)
Creates a less than qualifier given the expressions.javax.lang.model.element.AnnotationMirror
createLessThanQualifier(java.lang.String expression)
Returns@LessThan(expression)
.protected QualifierHierarchy
createQualifierHierarchy()
Returns theQualifierHierarchy
to be used by this checker.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.@Nullable java.util.List<java.lang.String>
getLessThanExpressions(com.sun.source.tree.ExpressionTree expression)
Returns a sorted, modifiable list of expressions thatexpression
is less than.@Nullable java.util.List<java.lang.String>
getLessThanExpressions(javax.lang.model.element.AnnotationMirror annotation)
If the annotation is LessThan, returns a list of expressions in the annotation.ValueAnnotatedTypeFactory
getValueAnnotatedTypeFactory()
Returns the Value Checker's annotated type factory.boolean
isLessThan(com.sun.source.tree.Tree left, java.lang.String right)
Returns true ifleft
is less thanright
.boolean
isLessThan(javax.lang.model.element.AnnotationMirror left, java.lang.String right)
Returns true ifleft
is less thanright
.boolean
isLessThanByValue(com.sun.source.tree.Tree smaller, java.lang.String bigger, com.sun.source.util.TreePath path)
Returns true ifsmaller < bigger
.boolean
isLessThanOrEqual(com.sun.source.tree.Tree left, java.lang.String right)
Returns true if left is less than or equal to right.boolean
isLessThanOrEqual(javax.lang.model.element.AnnotationMirror left, java.lang.String right)
Returns true if left is less than or equal to right.-
Methods inherited from class org.checkerframework.checker.index.BaseAnnotatedTypeFactoryForIndexChecker
hasSubsequenceFromValue, hasSubsequenceSubsequenceValue, hasSubsequenceToValue
-
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, applyInferredAnnotations, applyQualifierParameterDefaults, applyQualifierParameterDefaults, checkAndPerformFlowAnalysis, checkForDefaultQualifierInHierarchy, constructorFromUse, constructorFromUsePreSubstitution, createAndInitQualifierDefaults, createCFGVisualizer, createContractsFromMethod, createDefaultForTypeAnnotator, createDefaultForUseTypeAnnotator, createFlowTransferFunction, createQualifierDefaults, createQualifierPolymorphism, createRequiresOrEnsuresQualifier, createTreeAnnotator, createTypeAnnotator, 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, canonicalAnnotation, compoundAssignmentTreeArgTypes, containsSameByClass, containsUninferredTypeArguments, createAnnotatedTypeFormatter, createAnnotationClassLoader, createAnnotationFormatter, createQualifierUpperBounds, createTypeArgumentInference, createTypeHierarchy, 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, getDummyAssignedTo, getElementUtils, getEnclosingClassOrMethod, 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, getWidenedAnnotations, getWidenedType, getWidenedType, hasExplicitNoQualifierParameterInHierarchy, hasExplicitQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, initializeReflectionResolution, isFromByteCode, isFromStubFile, isImmutable, isSideEffectFree, isSupportedQualifier, isSupportedQualifier, isSupportedQualifier, isWithinConstructor, mergeAnnotationFileAnnosIntoType, methodFromUse, negateConstant, order, parseAnnotationFiles, postProcessClassTree, replaceAnnotations, replaceAnnotations, setPathForArtificialTree, setVisitorTreePath, shouldWarnIfStubRedundantWithBytecode, toAnnotatedType, toString, type
-
-
-
-
Constructor Detail
-
LessThanAnnotatedTypeFactory
public LessThanAnnotatedTypeFactory(BaseTypeChecker checker)
Creates a new LessThanAnnotatedTypeFactory.- Parameters:
checker
- the type-checker associated with this type factory
-
-
Method Detail
-
getValueAnnotatedTypeFactory
public ValueAnnotatedTypeFactory getValueAnnotatedTypeFactory()
Returns the Value Checker's annotated type factory.- Returns:
- the Value Checker's annotated type factory
-
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:
-
createDependentTypesHelper
protected DependentTypesHelper createDependentTypesHelper()
Description copied from class:GenericAnnotatedTypeFactory
Creates aDependentTypesHelper
and returns it. UseGenericAnnotatedTypeFactory.getDependentTypesHelper()
to access the value.- Overrides:
createDependentTypesHelper
in classGenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>
- Returns:
- a new
DependentTypesHelper
-
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
-
isLessThan
public boolean isLessThan(com.sun.source.tree.Tree left, java.lang.String right)
Returns true ifleft
is less thanright
.- Parameters:
left
- the first tree to compareright
- the second tree to compare- Returns:
- is left less than right?
-
isLessThan
public boolean isLessThan(javax.lang.model.element.AnnotationMirror left, java.lang.String right)
Returns true ifleft
is less thanright
.- Parameters:
left
- the first value to compare (an annotation)right
- the second value to compare (an expression)- Returns:
- is left less than right?
-
isLessThanByValue
public boolean isLessThanByValue(com.sun.source.tree.Tree smaller, java.lang.String bigger, com.sun.source.util.TreePath path)
Returns true ifsmaller < bigger
.- Parameters:
smaller
- the first value to comparebigger
- the second value to comparepath
- used to parse expressions strings- Returns:
smaller < bigger
, using information from the Value Checker
-
isLessThanOrEqual
public boolean isLessThanOrEqual(com.sun.source.tree.Tree left, java.lang.String right)
Returns true if left is less than or equal to right.- Parameters:
left
- the first value to compareright
- the second value to compare- Returns:
- is left less than or equal to right?
-
isLessThanOrEqual
public boolean isLessThanOrEqual(javax.lang.model.element.AnnotationMirror left, java.lang.String right)
Returns true if left is less than or equal to right.- Parameters:
left
- the first value to compareright
- the second value to compare- Returns:
- is left less than or equal to right?
-
getLessThanExpressions
public @Nullable java.util.List<java.lang.String> getLessThanExpressions(com.sun.source.tree.ExpressionTree expression)
Returns a sorted, modifiable list of expressions thatexpression
is less than. If theexpression
is annotated withLessThanBottom
, null is returned.- Parameters:
expression
- an expression- Returns:
- expressions that
expression
is less than
-
createLessThanQualifier
public javax.lang.model.element.AnnotationMirror createLessThanQualifier(@Nullable java.util.List<java.lang.String> expressions)
Creates a less than qualifier given the expressions.If expressions is null,
LessThanBottom
is returned. If expressions is empty,LessThanUnknown
is returned. Otherwise,@LessThan(expressions)
is returned.- Parameters:
expressions
- a list of expressions- Returns:
- a @LessThan qualifier with the given arguments
-
createLessThanQualifier
public javax.lang.model.element.AnnotationMirror createLessThanQualifier(java.lang.String expression)
Returns@LessThan(expression)
.
-
getLessThanExpressions
public @Nullable java.util.List<java.lang.String> getLessThanExpressions(javax.lang.model.element.AnnotationMirror annotation)
If the annotation is LessThan, returns a list of expressions in the annotation. If the annotation isLessThanBottom
, returns null. If the annotation isLessThanUnknown
, returns the empty list.- Parameters:
annotation
- an annotation from the same hierarchy as LessThan- Returns:
- the list of expressions in the annotation
-
-