public class RegexClassicAnnotatedTypeFactory extends GenericAnnotatedTypeFactory<CFValue,CFStore,RegexTransfer,RegexAnalysis>
Regex
to the type of tree, in the following cases:
String
or char
literal that is a valid
regular expressionString
or char
) or two partial regular expression
values that make a valid regular expression when concatenated.@Regex String
with the same group count as the second argument to the
call to asRegex.PartialRegex
is added
to the type of tree in the following cases:
PolyRegex
to the type of String/char concatenation of
a Regex and a PolyRegex or two PolyRegexs.GenericAnnotatedTypeFactory.ScanState
AnnotatedTypeFactory.InheritedFromClassAnnotator
Modifier and Type | Field and Description |
---|---|
protected AnnotationMirror |
PARTIALREGEX |
protected AnnotationMirror |
POLYREGEX |
protected AnnotationMirror |
REGEX |
protected AnnotationMirror |
REGEXBOTTOM |
protected ExecutableElement |
regexValueElement |
analyses, cfgVisualizer, defaults, FLOW_BY_DEFAULT, flowResult, initializationStaticStore, initializationStore, methodInvocationStores, poly, regularExitStores, returnStatementStores, scannedClasses, treeAnnotator, typeAnnotator
checker, elements, fromTreeCache, loader, processingEnv, qualHierarchy, reflectionResolver, root, shouldCache, trees, typeArgumentInference, typeFormatter, typeHierarchy, types, typeVarSubstitutor, uid, visitorState
Constructor and Description |
---|
RegexClassicAnnotatedTypeFactory(BaseTypeChecker checker) |
Modifier and Type | Method and Description |
---|---|
protected RegexAnalysis |
createFlowAnalysis(List<Pair<VariableElement,CFValue>> fieldValues)
Returns the appropriate flow analysis class that is used for the org.checkerframework.dataflow
analysis.
|
QualifierHierarchy |
createQualifierHierarchy(MultiGraphQualifierHierarchy.MultiGraphFactory factory)
Factory method to easily change what QualifierHierarchy is
created.
|
protected Set<Class<? extends Annotation>> |
createSupportedTypeQualifiers()
Returns a mutable set of annotation classes that are supported by a checker
|
TreeAnnotator |
createTreeAnnotator()
Returns a
TreeAnnotator that adds annotations to a type based
on the contents of a tree. |
int |
getGroupCount(AnnotationMirror anno)
Returns the group count value of the given annotation or 0 if
there's a problem getting the group count value.
|
static int |
getGroupCount(String regex)
Returns the number of groups in the given regex String.
|
addCheckedCodeDefaults, addComputedTypeAnnotations, addComputedTypeAnnotations, addComputedTypeAnnotations, addTypeNameImplicit, addUncheckedCodeDefaults, analyze, analyze, applyInferredAnnotations, checkAndPerformFlowAnalysis, constructorFromUse, createCFGVisualizer, createFlowTransferFunction, createQualifierDefaults, createQualifierPolymorphism, createTypeAnnotator, getAnnotatedTypeLhs, getAnnotatedTypeLhsNoTypeVarDefault, getCFGVisualizer, getEmptyStore, getFinalLocalValues, getInferredValueFor, getNodeForTree, getRegularExitStore, getResultingTypeOfConstructorMemberReference, getReturnStatementStores, getShouldDefaultTypeVarLocals, getSortedQualifierNames, getStoreAfter, getStoreBefore, getStoreBefore, getSupportedMonotonicTypeQualifiers, getTypeFactoryOfSubchecker, handleCFGViz, methodFromUse, performFlowAnalysis, postDirectSuperTypes, postInit, preProcessClassTree, setRoot
adaptGetClassReturnTypeToReceiver, addAliasedAnnotation, addAliasedDeclAnnotation, addInheritedAnnotation, aliasedAnnotation, annotateInheritedFromClass, annotateInheritedFromClass, checkInvalidOptionsInferSignatures, createAnnotatedTypeFormatter, createAnnotationFormatter, createQualifierHierarchy, createQualifierHierarchy, createQualifierHierarchyFactory, createTypeArgumentInference, createTypeHierarchy, createTypeVariableSubstitutor, declarationFromElement, fromElement, fromElement, fromElement, fromNewClass, getAnnotatedNullType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedTypeFromTypeTree, getAnnotationFormatter, getAnnotationMirror, getAnnotationWithMetaAnnotation, getBoxedType, getBundledTypeQualifiersWithoutPolyAll, getBundledTypeQualifiersWithPolyAll, getContext, getCurrentClassTree, getCurrentClassType, getCurrentMethodReceiver, getDeclAnnotation, getDeclAnnotationNoAliases, getDeclAnnotations, getDeclAnnotationWithMetaAnnotation, getElementUtils, getEnclosingMethod, getEnclosingType, getFnInterfaceFromTree, getFnInterfaceFromTree, getImplicitReceiverType, getMethodReturnType, getMethodReturnType, getNarrowedPrimitive, getPath, getProcessingEnv, getQualifierHierarchy, getReceiverType, getSelfType, getStringType, getSupportedTypeQualifiers, getTreeUtils, getTypeArgumentInference, getTypeHierarchy, getTypeVarSubstitutor, getUnboxedType, getUninferredWildcardType, getVisitorState, getWholeProgramInference, initilizeReflectionResolution, isAnyEnclosingThisDeref, isFromByteCode, isFromStubFile, isMostEnclosingThisDeref, isSupportedQualifier, isWithinConstructor, methodFromUse, parseStubFiles, postAsMemberOf, postProcessClassTree, postTypeVarSubstitution, setPathHack, toAnnotatedType, toString, type, typeVariablesFromUse, widenToUpperBound
protected final AnnotationMirror REGEX
protected final AnnotationMirror REGEXBOTTOM
protected final AnnotationMirror PARTIALREGEX
protected final AnnotationMirror POLYREGEX
protected final ExecutableElement regexValueElement
public RegexClassicAnnotatedTypeFactory(BaseTypeChecker checker)
protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers()
AnnotatedTypeFactory
Subclasses may override this method and 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 PolyAll
, and 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.
Annotations located outside the qual subdirectory, or has other
ElementType
values must be explicitly listed in code by overriding
the
AnnotatedTypeFactory.createSupportedTypeQualifiers()
method, as shown below.
Lastly, for checkers that do not want to support PolyAll
, it must
also be explicitly written in code, as shown below.
In total, there are 5 ways to indicate annotations that are supported by a checker:
PolyAll
:
This is the default behavior. Simply place those annotations within the qual directory.
PolyAll
:
Place those annotations within the qual directory, and override
AnnotatedTypeFactory.createSupportedTypeQualifiers()
by calling
AnnotatedTypeFactory.getBundledTypeQualifiersWithPolyAll(Class...)
with no
parameters passed in. Code example:
@Override protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers() {
return getBundledTypeQualifiersWithoutPolyAll();
}
PolyAll
, and a list of other annotations:
Place those annotations within the qual directory, and override
AnnotatedTypeFactory.createSupportedTypeQualifiers()
by calling
AnnotatedTypeFactory.getBundledTypeQualifiersWithPolyAll(Class...)
with a
varargs parameter list of the other annotations. Code example:
@Override protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers() {
return getBundledTypeQualifiersWithPolyAll(Regex.class, PartialRegex.class, RegexBottom.class, UnknownRegex.class);
}
PolyAll
:
Place those annotations within the qual directory, and override
AnnotatedTypeFactory.createSupportedTypeQualifiers()
by calling
AnnotatedTypeFactory.getBundledTypeQualifiersWithoutPolyAll(Class...)
with a
varargs parameter list of the other annotations. Code example:
@Override protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers() {
return getBundledTypeQualifiersWithoutPolyAll(UnknownFormat.class, FormatBottom.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.getBundledTypeQualifiersWithoutPolyAll(Class...)
and
AnnotatedTypeFactory.getBundledTypeQualifiersWithPolyAll(Class...)
each
must return a fresh, mutable set
createSupportedTypeQualifiers
in class AnnotatedTypeFactory
protected RegexAnalysis createFlowAnalysis(List<Pair<VariableElement,CFValue>> fieldValues)
GenericAnnotatedTypeFactory
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.
createFlowAnalysis
in class GenericAnnotatedTypeFactory<CFValue,CFStore,RegexTransfer,RegexAnalysis>
public TreeAnnotator createTreeAnnotator()
GenericAnnotatedTypeFactory
TreeAnnotator
that adds annotations to a type based
on the contents of a tree.
Subclasses may override this method to specify a more appropriate
TreeAnnotator
.createTreeAnnotator
in class GenericAnnotatedTypeFactory<CFValue,CFStore,RegexTransfer,RegexAnalysis>
public QualifierHierarchy createQualifierHierarchy(MultiGraphQualifierHierarchy.MultiGraphFactory factory)
AnnotatedTypeFactory
createQualifierHierarchy
in class AnnotatedTypeFactory
public int getGroupCount(AnnotationMirror anno)
public static int getGroupCount(String regex)