
org.checkerframework.common.accumulation.AccumulationVisitor 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.common.accumulation;
import com.sun.source.tree.AnnotationTree;
import org.checkerframework.common.basetype.BaseTypeChecker;
import org.checkerframework.common.basetype.BaseTypeVisitor;
import org.checkerframework.javacutil.TreeUtils;
import javax.lang.model.element.AnnotationMirror;
/**
* The visitor for an accumulation checker. Issues predicate.invalid errors if the user writes an
* invalid predicate.
*/
public class AccumulationVisitor extends BaseTypeVisitor {
/**
* Constructor matching super.
*
* @param checker the checker
*/
public AccumulationVisitor(BaseTypeChecker checker) {
super(checker);
}
/** Checks each predicate annotation to make sure the predicate is well-formed. */
@Override
public Void visitAnnotation(AnnotationTree tree, Void p) {
AnnotationMirror anno = TreeUtils.annotationFromAnnotationTree(tree);
if (atypeFactory.isPredicate(anno)) {
String errorMessage = atypeFactory.isValidPredicate(anno);
if (errorMessage != null) {
checker.reportError(tree, "predicate.invalid", errorMessage);
}
}
return super.visitAnnotation(tree, p);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy