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

org.checkerframework.common.accumulation.AccumulationVisitor 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.common.accumulation;

import com.sun.source.tree.AnnotationTree;
import javax.lang.model.element.AnnotationMirror;
import org.checkerframework.common.basetype.BaseTypeChecker;
import org.checkerframework.common.basetype.BaseTypeVisitor;
import org.checkerframework.javacutil.TreeUtils;

/**
 * The visitor for an accumulation checker. Issues predicate 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(final AnnotationTree node, final Void p) {
    AnnotationMirror anno = TreeUtils.annotationFromAnnotationTree(node);
    if (atypeFactory.isPredicate(anno)) {
      String errorMessage = atypeFactory.isValidPredicate(anno);
      if (errorMessage != null) {
        checker.reportError(node, "predicate", errorMessage);
      }
    }
    return super.visitAnnotation(node, p);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy