Class TypedInsertion

java.lang.Object
org.checkerframework.afu.annotator.find.Insertion
org.checkerframework.afu.annotator.find.TypedInsertion
Direct Known Subclasses:
ConstructorInsertion, NewInsertion, ReceiverInsertion

public abstract class TypedInsertion extends Insertion
An insertion that may result in code generation other than just annotations. TypedInsertions keep track of insertions on inner types. If there is no type given in the source, one may be generated (along with other code necessary in the context) to serve as an insertion site.

We don't know until the end of the whole insertion process whether the type already exists or not. To remedy this, we store a reference to each insertion on an inner type of a receiver in two places: the global list of all insertions and the TypedInsertion that is the parent of the inner type insertion. If the type is not already present, the inner type insertions are inserted into the new type and labeled as "inserted" (with Insertion.setInserted(boolean)) so they are not inserted as the rest of the insertions list is processed.

  • Field Details

    • type

      protected Type type
      The type for insertion.
    • annotationsOnly

      protected boolean annotationsOnly
      If true only the annotations from type will be inserted.
    • innerTypeInsertions

      protected List<Insertion> innerTypeInsertions
      The inner types to go on this insertion. See ReceiverInsertion for more details.
  • Constructor Details

  • Method Details

    • setAnnotationsOnly

      public void setAnnotationsOnly(boolean annotationsOnly)
      If true only the annotations on type will be inserted. This is useful when the "new" has already been inserted.
    • setType

      public void setType(Type type)
      Sets the type.
    • getType

      public Type getType()
      Gets the type. It is assumed that the returned value will be modified to update the type to be inserted.
    • getInnerTypeInsertions

      public List<Insertion> getInnerTypeInsertions()
      Gets the inner type insertions associated with this insertion.
      Returns:
      a copy of the inner types
    • getBaseType

      public DeclaredType getBaseType()
    • getBaseType

      public static DeclaredType getBaseType(Type type)