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

framework.src.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.42.0
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy