All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.checkerframework.framework.type.treeannotator.ListTreeAnnotator Maven / Gradle / Ivy

Go to download

The Checker Framework enhances Java's type system to make it more powerful and useful. This lets software developers detect and prevent errors in their Java programs. The Checker Framework includes compiler plug-ins ("checkers") that find bugs or verify their absence. It also permits you to write your own compiler plug-ins.

There is a newer version: 3.44.0
Show newest version
package org.checkerframework.framework.type.treeannotator;

import com.sun.source.tree.Tree;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.checkerframework.framework.type.AnnotatedTypeMirror;

/**
 * ListTreeAnnotator is a TreeVisitor that executes a list of {@link TreeAnnotator} for each tree
 * visited.
 *
 * 

Checkers should not extend ListTreeAnnotator; they should instead pass a custom TreeAnnotator * to the constructor. * * @see LiteralTreeAnnotator * @see PropagationTreeAnnotator */ public class ListTreeAnnotator extends TreeAnnotator { protected final List annotators; /** * @param annotators the annotators that will be executed for each tree scanned by this * TreeAnnotator. They are executed in the order passed in. */ public ListTreeAnnotator(TreeAnnotator... annotators) { this(Arrays.asList(annotators)); } /** * @param annotators the annotators that will be executed for each tree scanned by this * TreeAnnotator. They are executed in the order passed in. */ public ListTreeAnnotator(List annotators) { super(null); List annotatorList = new ArrayList<>(annotators.size()); for (TreeAnnotator annotator : annotators) { if (annotator instanceof ListTreeAnnotator) { annotatorList.addAll(((ListTreeAnnotator) annotator).annotators); } else { annotatorList.add(annotator); } } this.annotators = Collections.unmodifiableList(annotatorList); } @Override public Void defaultAction(Tree node, AnnotatedTypeMirror type) { for (TreeAnnotator annotator : annotators) { annotator.visit(node, type); } return null; } @Override public String toString() { return "ListTreeAnnotator(" + annotators + ")"; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy