framework.src.org.checkerframework.framework.type.treeannotator.ListTreeAnnotator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of checker Show documentation
Show all versions of checker Show documentation
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.
package org.checkerframework.framework.type.treeannotator;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import com.sun.source.tree.Tree;
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 ImplicitsTreeAnnotator
* @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) {
super(null);
this.annotators = Collections.unmodifiableList(Arrays.asList(annotators));
}
@Override
public Void defaultAction(Tree node, AnnotatedTypeMirror type) {
for (TreeAnnotator annotator : annotators) {
annotator.visit(node, type);
}
return null;
}
}