Search in sources :

Example 1 with TreeAnnotator

use of org.checkerframework.framework.type.treeannotator.TreeAnnotator 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);
}
Also used : LiteralTreeAnnotator(org.checkerframework.framework.type.treeannotator.LiteralTreeAnnotator) PropagationTreeAnnotator(org.checkerframework.framework.type.treeannotator.PropagationTreeAnnotator) ArrayList(java.util.ArrayList) LiteralTreeAnnotator(org.checkerframework.framework.type.treeannotator.LiteralTreeAnnotator) PropagationTreeAnnotator(org.checkerframework.framework.type.treeannotator.PropagationTreeAnnotator) TreeAnnotator(org.checkerframework.framework.type.treeannotator.TreeAnnotator) ListTreeAnnotator(org.checkerframework.framework.type.treeannotator.ListTreeAnnotator) DependentTypesTreeAnnotator(org.checkerframework.framework.util.dependenttypes.DependentTypesTreeAnnotator) ListTreeAnnotator(org.checkerframework.framework.type.treeannotator.ListTreeAnnotator)

Aggregations

ArrayList (java.util.ArrayList)1 ListTreeAnnotator (org.checkerframework.framework.type.treeannotator.ListTreeAnnotator)1 LiteralTreeAnnotator (org.checkerframework.framework.type.treeannotator.LiteralTreeAnnotator)1 PropagationTreeAnnotator (org.checkerframework.framework.type.treeannotator.PropagationTreeAnnotator)1 TreeAnnotator (org.checkerframework.framework.type.treeannotator.TreeAnnotator)1 DependentTypesTreeAnnotator (org.checkerframework.framework.util.dependenttypes.DependentTypesTreeAnnotator)1