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

org.checkerframework.javacutil.AnnotationProvider 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.javacutil;

import com.sun.source.tree.Tree;
import java.lang.annotation.Annotation;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import org.checkerframework.checker.nullness.qual.Nullable;

// This class exists to break a circular dependency between the dataflow framework and
// type-checkers.
/** An implementation of AnnotationProvider returns annotations on Java AST elements. */
public interface AnnotationProvider {

  /**
   * Returns the AnnotationMirror, of the given class or an alias of it, used to annotate the
   * element. Returns null if no annotation equivalent to {@code anno} exists on {@code elt}.
   *
   * @param elt the element
   * @param anno annotation class
   * @return an annotation mirror of class {@code anno} on {@code elt}, or an equivalent one, or
   *     null if none exists on {@code anno}
   */
  @Nullable AnnotationMirror getDeclAnnotation(Element elt, Class anno);

  /**
   * Return the annotation on {@code tree} that is in the hierarchy that contains the qualifier
   * {@code target}. Returns null if none exists.
   *
   * @param tree the tree of which the annotation is returned
   * @param target the class of the annotation
   * @return the annotation on {@code tree} that has the class {@code target}, or null
   */
  @Nullable AnnotationMirror getAnnotationMirror(Tree tree, Class target);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy