use of org.checkerframework.framework.type.treeannotator.LiteralTreeAnnotator in project checker-framework by typetools.
the class SignatureAnnotatedTypeFactory method signatureLiteralTreeAnnotator.
/**
* Create a LiteralTreeAnnotator for the Signature Checker.
*
* @param atypeFactory the type factory
* @return a LiteralTreeAnnotator for the Signature Checker
*/
private LiteralTreeAnnotator signatureLiteralTreeAnnotator(AnnotatedTypeFactory atypeFactory) {
LiteralTreeAnnotator result = new LiteralTreeAnnotator(atypeFactory);
result.addStandardLiteralQualifiers();
// The below code achieves the same effect as writing a meta-annotation
// @QualifierForLiterals(stringPatterns = "...")
// on each type qualifier definition. Annotation elements cannot be computations (not even
// string concatenations of literal strings) and cannot be not references to compile-time
// constants such as effectively-final fields. So every `stringPatterns = "..."` would have
// to be a literal string, which would be verbose ard hard to maintain.
result.addStringPattern(SignatureRegexes.ArrayWithoutPackageRegex, AnnotationBuilder.fromClass(elements, ArrayWithoutPackage.class));
result.addStringPattern(SignatureRegexes.BinaryNameRegex, AnnotationBuilder.fromClass(elements, BinaryName.class));
result.addStringPattern(SignatureRegexes.BinaryNameOrPrimitiveTypeRegex, AnnotationBuilder.fromClass(elements, BinaryNameOrPrimitiveType.class));
result.addStringPattern(SignatureRegexes.BinaryNameWithoutPackageRegex, AnnotationBuilder.fromClass(elements, BinaryNameWithoutPackage.class));
result.addStringPattern(SignatureRegexes.ClassGetNameRegex, AnnotationBuilder.fromClass(elements, ClassGetName.class));
result.addStringPattern(SignatureRegexes.ClassGetSimpleNameRegex, AnnotationBuilder.fromClass(elements, ClassGetSimpleName.class));
result.addStringPattern(SignatureRegexes.DotSeparatedIdentifiersRegex, AnnotationBuilder.fromClass(elements, DotSeparatedIdentifiers.class));
result.addStringPattern(SignatureRegexes.DotSeparatedIdentifiersOrPrimitiveTypeRegex, AnnotationBuilder.fromClass(elements, DotSeparatedIdentifiersOrPrimitiveType.class));
result.addStringPattern(SignatureRegexes.FieldDescriptorRegex, AnnotationBuilder.fromClass(elements, FieldDescriptor.class));
result.addStringPattern(SignatureRegexes.FieldDescriptorForPrimitiveRegex, AnnotationBuilder.fromClass(elements, FieldDescriptorForPrimitive.class));
result.addStringPattern(SignatureRegexes.FieldDescriptorWithoutPackageRegex, AnnotationBuilder.fromClass(elements, FieldDescriptorWithoutPackage.class));
result.addStringPattern(SignatureRegexes.FqBinaryNameRegex, AnnotationBuilder.fromClass(elements, FqBinaryName.class));
result.addStringPattern(SignatureRegexes.FullyQualifiedNameRegex, AnnotationBuilder.fromClass(elements, FullyQualifiedName.class));
result.addStringPattern(SignatureRegexes.IdentifierRegex, AnnotationBuilder.fromClass(elements, Identifier.class));
result.addStringPattern(SignatureRegexes.IdentifierOrPrimitiveTypeRegex, AnnotationBuilder.fromClass(elements, IdentifierOrPrimitiveType.class));
result.addStringPattern(SignatureRegexes.InternalFormRegex, AnnotationBuilder.fromClass(elements, InternalForm.class));
result.addStringPattern(SignatureRegexes.PrimitiveTypeRegex, AnnotationBuilder.fromClass(elements, PrimitiveType.class));
return result;
}
use of org.checkerframework.framework.type.treeannotator.LiteralTreeAnnotator in project checker-framework by typetools.
the class GenericAnnotatedTypeFactory method createTreeAnnotator.
/**
* Returns a {@link TreeAnnotator} that adds annotations to a type based on the contents of a
* tree.
*
* <p>The default tree annotator is a {@link ListTreeAnnotator} of the following:
*
* <ol>
* <li>{@link PropagationTreeAnnotator}: Propagates annotations from subtrees
* <li>{@link LiteralTreeAnnotator}: Adds annotations based on {@link QualifierForLiterals}
* meta-annotations
* <li>{@link DependentTypesTreeAnnotator}: Adapts dependent annotations based on context
* </ol>
*
* <p>Subclasses may override this method to specify additional tree annotators, for example:
*
* <pre>
* new ListTreeAnnotator(super.createTreeAnnotator(), new KeyLookupTreeAnnotator(this));
* </pre>
*
* @return a tree annotator
*/
protected TreeAnnotator createTreeAnnotator() {
List<TreeAnnotator> treeAnnotators = new ArrayList<>(2);
treeAnnotators.add(new PropagationTreeAnnotator(this));
treeAnnotators.add(new LiteralTreeAnnotator(this).addStandardLiteralQualifiers());
if (dependentTypesHelper.hasDependentAnnotations()) {
treeAnnotators.add(dependentTypesHelper.createDependentTypesTreeAnnotator());
}
return new ListTreeAnnotator(treeAnnotators);
}
use of org.checkerframework.framework.type.treeannotator.LiteralTreeAnnotator in project checker-framework by typetools.
the class AinferTestAnnotatedTypeFactory method createTreeAnnotator.
@Override
public TreeAnnotator createTreeAnnotator() {
LiteralTreeAnnotator literalTreeAnnotator = new LiteralTreeAnnotator(this);
literalTreeAnnotator.addLiteralKind(LiteralKind.INT, BOTTOM);
literalTreeAnnotator.addStandardLiteralQualifiers();
return new ListTreeAnnotator(new PropagationTreeAnnotator(this), literalTreeAnnotator);
}
use of org.checkerframework.framework.type.treeannotator.LiteralTreeAnnotator in project checker-framework by typetools.
the class ReflectionTestAnnotatedTypeFactory method createTreeAnnotator.
@Override
public TreeAnnotator createTreeAnnotator() {
LiteralTreeAnnotator literalTreeAnnotator = new LiteralTreeAnnotator(this);
AnnotationMirror bottom = AnnotationBuilder.fromClass(elements, ReflectBottom.class);
literalTreeAnnotator.addLiteralKind(LiteralKind.INT, bottom);
literalTreeAnnotator.addStandardLiteralQualifiers();
return new ListTreeAnnotator(new PropagationTreeAnnotator(this), literalTreeAnnotator);
}
Aggregations