Class AnnotationInsertion

java.lang.Object
org.checkerframework.afu.annotator.find.Insertion
org.checkerframework.afu.annotator.find.AnnotationInsertion
Direct Known Subclasses:
TypeBoundExtendsInsertion

public class AnnotationInsertion extends Insertion
Specifies an annotation to be inserted into a source file.
  • Constructor Details

    • AnnotationInsertion

      public AnnotationInsertion(String fullyQualifiedAnnotationText, Criteria criteria, boolean separateLine)
      Creates a new insertion.
      Parameters:
      fullyQualifiedAnnotationText - the annotation text to be inserted into source code; starts with "@", and must be a fully-qualified name
      criteria - where to insert the annotation
      separateLine - if true, insert the annotation on its own line
    • AnnotationInsertion

      public AnnotationInsertion(String fullyQualifiedAnnotationText, Criteria criteria, boolean separateLine, Annotation annotation)
      Creates a new insertion.
      Parameters:
      fullyQualifiedAnnotationText - the annotation text to be inserted into source code; starts with "@", and must be a fully-qualified name
      criteria - where to insert the annotation
      separateLine - if true, insert the annotation on its own line
      annotation - the annotation being inserted
    • AnnotationInsertion

      public AnnotationInsertion(String annotation)
      Creates a new insertion with an empty criteria and the text inserted on the same line.
      Parameters:
      annotation - the text to insert
  • Method Details

    • isGenerateExtends

      public boolean isGenerateExtends()
    • isGenerateBound

      public boolean isGenerateBound()
    • setGenerateExtends

      public void setGenerateExtends(boolean generateExtends)
    • setGenerateBound

      public void setGenerateBound(boolean b)
    • getText

      protected String getText(boolean abbreviate)
      Gets the insertion text.
      Specified by:
      getText in class Insertion
      Parameters:
      abbreviate - if true, the package name will be removed from the annotation
      Returns:
      the text to insert
    • getAnnotationText

      public String getAnnotationText()
      Gets the raw, unmodified annotation that was passed into the constructor.
      Returns:
      the annotation
    • getAnnotationFullyQualifiedName

      public String getAnnotationFullyQualifiedName()
      Returns the fully-qualified name of the annotation.

      E.g. given @com.foo.Bar(baz), the fully-qualified name of this annotation is com.foo.Bar.

      Returns:
      the annotation's fully-qualified name
    • addLeadingSpace

      protected boolean addLeadingSpace(boolean gotSeparateLine, int pos, char precedingChar)
      Description copied from class: Insertion
      Indicates if a preceding space should be added to this insertion. Subclasses may override this method for custom leading space rules.
      Overrides:
      addLeadingSpace in class Insertion
      Parameters:
      gotSeparateLine - true if this insertion is actually added on a separate line
      pos - the source position where this insertion will be inserted
      precedingChar - the character directly preceding where this insertion will be inserted. This value will be ignored if pos is 0.
      Returns:
      true if a leading space should be added, false otherwise
    • addTrailingSpace

      protected boolean addTrailingSpace(boolean gotSeparateLine)
      Description copied from class: Insertion
      Indicates if a trailing space should be added to this insertion. Subclasses may override this method for custom trailing space rules.
      Overrides:
      addTrailingSpace in class Insertion
      Parameters:
      gotSeparateLine - true if this insertion is actually added on a separate line
      Returns:
      true if a trailing space should be added, false otherwise
    • getKind

      public Insertion.Kind getKind()
      Description copied from class: Insertion
      Gets the kind of this insertion.
      Specified by:
      getKind in class Insertion
      Returns:
      the kind of this insertion
    • toString

      public String toString()
      Overrides:
      toString in class Insertion
    • setType

      public void setType(String s)
    • getAnnotation

      public Annotation getAnnotation()
      Returns the annotation being inserted.
      Returns:
      the annotation being inserted