Class AElement

java.lang.Object
org.checkerframework.afu.scenelib.el.AElement
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
ADeclaration, AExpression, AnnotationDef, ATypeElement

public class AElement extends Object implements Cloneable
An AElement represents a Java element and the annotations it carries. Some AElements may contain others; for example, an AClass may contain AMethods. Every AElement usually belongs directly or indirectly to an AScene. Each subclass of AElement represents one kind of annotatable element; its name should make this clear.

The name AElement stands for "annotatable element" or "annotated element".

  • Field Details

    • tlAnnotationsHere

      public final Set<Annotation> tlAnnotationsHere
      The top-level annotations directly on this element. Annotations on subelements are in those subelements' tlAnnotationsHere sets, not here.
    • type

      public final ATypeElement type
      The type of a field or a method parameter.

      When this AElement object is a field or method parameter, its annotations are declaration annotations, and the type field represents its type, whose annotations are type annotations.

      When this AElement object is NOT a field or method parameter, the type field is null.

    • description

      public Object description
      A description of the element. Used for debugging and diagnostic messages. Almost always a String, but in ATypeElement it is an ASTPath.
  • Method Details

    • clone

      public AElement clone()
      Overrides:
      clone in class Object
    • equals

      public boolean equals(Object o)
      Returns true if this AElement equals o (see warnings below). Generally speaking, two AElements are equal if they are of the same type, have the same tlAnnotationsHere, and have recursively equal, corresponding subelements. Two warnings:
      • While subelement collections usually remember the order in which subelements were added and regurgitate them in this order, two AElements are equal even if order of subelements differs.
      • Two AElements are unequal if one has a subelement that the other does not, even if the tree of elements rooted at the subelement contains no annotations. Thus, if you want to compare the annotations, you should prune() both AElements first.
      Overrides:
      equals in class Object
    • equals

      public boolean equals(AElement o)
      Returns true if this AElement equals o. This is a slightly faster variant of equals(Object) for when the argument is statically known to be another nonnull AElement.
      Parameters:
      o - the AElement to compare to
      Returns:
      true if this is equal to o
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • isEmpty

      public boolean isEmpty()
      Returns true if this AElement is empty.
      Returns:
      true iff this is empty
    • prune

      public void prune()
      Removes empty subelements of this AElement depth-first.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • lookup

      public Annotation lookup(String name)
      Returns the top-level annotation on this that has the given name. Return null if no such annotation exists.
      Parameters:
      name - the fully-qualified type name of the annotation to search for
      Returns:
      the annotation on this with the given name, or null if none exists
    • tlAnnotationsHereFormatted

      public void tlAnnotationsHereFormatted(StringBuilder sb)
    • accept

      public <R, T> R accept(ElementVisitor<R,T> v, T t)