public class LessThanAnnotatedTypeFactory extends BaseAnnotatedTypeFactoryForIndexChecker
GenericAnnotatedTypeFactory.ScanState
AnnotatedTypeFactory.ParameterizedExecutableType
Modifier and Type | Field and Description |
---|---|
AnnotationMirror |
LESS_THAN_UNKNOWN
The @LessThanUnknown annotation.
|
hasSubsequenceFromElement, hasSubsequenceSubsequenceElement, hasSubsequenceToElement
analysis, cfgVisualizer, contractsUtils, defaults, dependentTypesHelper, emptyStore, exceptionalExitStores, flowByDefault, flowResult, flowResultAnalysisCaches, hasOrIsSubchecker, initializationStaticStore, initializationStore, methodInvocationStores, poly, regularExitStores, relevantJavaTypes, returnStatementStores, scannedClasses, shouldClearSubcheckerSharedCFGs, sideEffectsUnrefineAliases, subcheckerSharedCFG, transfer, treeAnnotator, typeAnnotator
ajavaTypes, artificialTreeToEnclosingElementMap, checker, currentFileAjavaTypes, elements, fromExpressionTreeCache, fromMemberTreeCache, fromTypeTreeCache, ignoreUninferredTypeArguments, loader, methodValClassNameElement, methodValMethodNameElement, methodValParamsElement, objectGetClass, processingEnv, qualHierarchy, qualifierUpperBounds, reflectionResolver, root, shouldCache, stubTypes, trees, typeArgumentInference, typeFormatter, typeHierarchy, types, typeVarSubstitutor, uid, visitorState, wpiOutputFormat
Constructor and Description |
---|
LessThanAnnotatedTypeFactory(BaseTypeChecker checker)
Creates a new LessThanAnnotatedTypeFactory.
|
Modifier and Type | Method and Description |
---|---|
protected DependentTypesHelper |
createDependentTypesHelper()
Creates a
DependentTypesHelper and returns it. |
AnnotationMirror |
createLessThanQualifier(List<String> expressions)
Creates a less than qualifier given the expressions.
|
AnnotationMirror |
createLessThanQualifier(String expression)
Returns
@LessThan(expression) . |
protected QualifierHierarchy |
createQualifierHierarchy()
Returns the
QualifierHierarchy to be used by this checker. |
protected Set<Class<? extends Annotation>> |
createSupportedTypeQualifiers()
Returns a mutable set of annotation classes that are supported by a checker.
|
List<String> |
getLessThanExpressions(AnnotationMirror annotation)
If the annotation is LessThan, returns a list of expressions in the annotation.
|
List<String> |
getLessThanExpressions(ExpressionTree expression)
Returns a sorted, modifiable list of expressions that
expression is less than. |
ValueAnnotatedTypeFactory |
getValueAnnotatedTypeFactory()
Returns the Value Checker's annotated type factory.
|
boolean |
isLessThan(AnnotationMirror left,
String right)
Returns true if
left is less than right . |
boolean |
isLessThan(Tree left,
String right)
Returns true if
left is less than right . |
boolean |
isLessThanByValue(Tree smaller,
String bigger,
TreePath path)
Returns true if
smaller < bigger . |
boolean |
isLessThanOrEqual(AnnotationMirror left,
String right)
Returns true if left is less than or equal to right.
|
boolean |
isLessThanOrEqual(Tree left,
String right)
Returns true if left is less than or equal to right.
|
hasSubsequenceFromValue, hasSubsequenceSubsequenceValue, hasSubsequenceToValue
createFlowAnalysis
addAnnotationsFromDefaultForType, addCheckedCodeDefaults, addCheckedStandardDefaults, addComputedTypeAnnotations, addComputedTypeAnnotations, addComputedTypeAnnotations, addDefaultAnnotations, addSharedCFGForTree, addUncheckedStandardDefaults, analyze, applyInferredAnnotations, applyQualifierParameterDefaults, applyQualifierParameterDefaults, checkAndPerformFlowAnalysis, checkForDefaultQualifierInHierarchy, constructorFromUse, constructorFromUsePreSubstitution, createAndInitQualifierDefaults, createCFGVisualizer, createContractsFromMethod, createDefaultForTypeAnnotator, createDefaultForUseTypeAnnotator, createFlowTransferFunction, createQualifierDefaults, createQualifierPolymorphism, createTreeAnnotator, createTypeAnnotator, fromNewClass, getAnnotatedTypeLhs, getAnnotatedTypeLhsNoTypeVarDefault, getAnnotatedTypeRhsUnaryAssign, getAnnotatedTypeVarargsArray, getAnnotationFromJavaExpression, getAnnotationFromJavaExpressionString, getAnnotationMirrorFromJavaExpressionString, getAnnotationsFromJavaExpression, getCFGVisualizer, getContractAnnotations, getContractAnnotations, getContractExpressions, getContractsFromMethod, getDefaultForTypeAnnotator, getDefaultValueAnnotatedType, getDependentTypesHelper, getEmptyStore, getEnsuresQualifierIfResult, getExceptionalExitStore, getExpressionAndOffsetFromJavaExpressionString, getFinalLocalValues, getFirstNodeOfKindForTree, getInferredValueFor, getMethodReturnType, getNodesForTree, getPostconditionAnnotation, getPostconditionAnnotations, getPostconditionAnnotations, getPreconditionAnnotation, getPreconditionAnnotations, getPreconditionAnnotations, getPreOrPostconditionAnnotation, getQualifierPolymorphism, getRegularExitStore, getResultingTypeOfConstructorMemberReference, getReturnStatementStores, getSharedCFGForTree, getShouldDefaultTypeVarLocals, getSortedQualifierNames, getStoreAfter, getStoreAfter, getStoreAfter, getStoreBefore, getStoreBefore, getStoreBefore, getSupportedMonotonicTypeQualifiers, getTypeFactoryOfSubchecker, handleCFGViz, isRelevant, methodFromUse, methodFromUsePreSubstitution, parseJavaExpressionString, performFlowAnalysis, postAnalyze, postAsMemberOf, postDirectSuperTypes, postInit, preProcessClassTree, requiresOrEnsuresQualifierAnno, setRoot, typeVariablesFromUse
adaptGetClassReturnTypeToReceiver, addAliasedAnnotation, addAliasedAnnotation, addAliasedAnnotation, addAliasedDeclAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAnnotationFromFieldInvariant, addInheritedAnnotation, applyCaptureConversion, applyCaptureConversion, applyUnboxing, areSameByClass, binaryTreeArgTypes, binaryTreeArgTypes, canonicalAnnotation, checkInvalidOptionsInferSignatures, compoundAssignmentTreeArgTypes, containsSameByClass, containsUninferredTypeArguments, createAnnotatedTypeFormatter, createAnnotationClassLoader, createAnnotationFormatter, createQualifierHierarchyWithMultiGraphFactory, createQualifierUpperBounds, createTypeArgumentInference, createTypeHierarchy, 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, getCurrentClassTree, getCurrentClassType, getCurrentMethodReceiver, getDeclAnnotation, getDeclAnnotationNoAliases, getDeclAnnotations, getDeclAnnotationWithMetaAnnotation, getDefaultTypeDeclarationBounds, getDummyAssignedTo, getElementUtils, getEnclosingClassOrMethod, getEnclosingElementForArtificialTree, getEnclosingType, getExpressionAndOffset, getFieldInvariantAnnotationTree, getFieldInvariantDeclarationAnnotations, getFieldInvariants, getFnInterfaceFromTree, getFunctionTypeFromTree, getFunctionTypeFromTree, getImplicitReceiverType, getIterableElementType, getIterableElementType, getMethodReturnType, getNarrowedAnnotations, getNarrowedPrimitive, getPath, getProcessingEnv, getQualifierHierarchy, getQualifierParameterHierarchies, getQualifierParameterHierarchies, getQualifierUpperBounds, getReceiverType, getSelfType, getStringType, getSupportedTypeQualifierNames, getSupportedTypeQualifiers, getTreeUtils, getTypeArgumentInference, getTypeDeclarationBounds, getTypeHierarchy, getTypeOfExtendsImplements, getTypeVarSubstitutor, getUnboxedType, getUninferredWildcardType, getVisitorState, getWholeProgramInference, getWidenedAnnotations, getWidenedType, getWidenedType, hasExplicitNoQualifierParameterInHierarchy, hasExplicitQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, initializeReflectionResolution, isFromByteCode, isFromStubFile, isSupportedQualifier, isSupportedQualifier, isSupportedQualifier, isWithinConstructor, mergeAnnotationFileAnnosIntoType, methodFromUse, negateConstant, order, parseAnnotationFiles, postProcessClassTree, postTypeVarSubstitution, prepareMethodForWriting, prepareMethodForWriting, replaceAnnotations, replaceAnnotations, setEnclosingElementForArtificialTree, shouldWarnIfStubRedundantWithBytecode, toAnnotatedType, toString, type, wpiAdjustForUpdateField, wpiAdjustForUpdateNonField
public final AnnotationMirror LESS_THAN_UNKNOWN
public LessThanAnnotatedTypeFactory(BaseTypeChecker checker)
checker
- the type-checker associated with this type factorypublic ValueAnnotatedTypeFactory getValueAnnotatedTypeFactory()
protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers()
AnnotatedTypeFactory
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 of ElementType.TYPE_PARAMETER
, but no other ElementType
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:
This is the default behavior. Simply place those annotations within the qual directory.
Place those annotations within the qual directory, and override AnnotatedTypeFactory.createSupportedTypeQualifiers()
by calling AnnotatedTypeFactory.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);
}
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));
}
The set of qualifiers returned by AnnotatedTypeFactory.createSupportedTypeQualifiers()
must be a
fresh, mutable set. The methods AnnotatedTypeFactory.getBundledTypeQualifiers(Class...)
must return a
fresh, mutable set
createSupportedTypeQualifiers
in class AnnotatedTypeFactory
protected DependentTypesHelper createDependentTypesHelper()
GenericAnnotatedTypeFactory
DependentTypesHelper
and returns it. Use GenericAnnotatedTypeFactory.getDependentTypesHelper()
to
access the value.createDependentTypesHelper
in class GenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>
DependentTypesHelper
protected QualifierHierarchy createQualifierHierarchy()
AnnotatedTypeFactory
QualifierHierarchy
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 of NoElementQualifierHierarchy
.
Subclasses must override this method if their qualifiers have elements; the method must
return an implementation of QualifierHierarchy
, such as ElementQualifierHierarchy
.
createQualifierHierarchy
in class AnnotatedTypeFactory
public boolean isLessThan(Tree left, String right)
left
is less than right
.left
- the first tree to compareright
- the second tree to comparepublic boolean isLessThan(AnnotationMirror left, String right)
left
is less than right
.left
- the first value to compare (an annotation)right
- the second value to compare (an expression)public boolean isLessThanByValue(Tree smaller, String bigger, TreePath path)
smaller < bigger
.smaller
- the first value to comparebigger
- the second value to comparesmaller < bigger
, using information from the Value Checkerpublic boolean isLessThanOrEqual(Tree left, String right)
left
- the first value to compareright
- the second value to comparepublic boolean isLessThanOrEqual(AnnotationMirror left, String right)
left
- the first value to compareright
- the second value to comparepublic List<String> getLessThanExpressions(ExpressionTree expression)
expression
is less than. If the
expression
is annotated with LessThanBottom
, null is returned.expression
- an expressionexpression
is less thanpublic AnnotationMirror createLessThanQualifier(List<String> expressions)
If expressions is null, LessThanBottom
is returned. If expressions is empty, LessThanUnknown
is returned. Otherwise, @LessThan(expressions)
is returned.
expressions
- a list of expressionspublic AnnotationMirror createLessThanQualifier(String expression)
@LessThan(expression)
.public List<String> getLessThanExpressions(AnnotationMirror annotation)
LessThanBottom
, returns null. If the annotation is LessThanUnknown
, returns the empty list.annotation
- an annotation from the same hierarchy as LessThan