Interface InsertionRef

All Known Implementing Classes:
InsertionPoint

public interface InsertionRef
A position in a source file where generated code will be inserted.

The two implementations count position differently — an index into a list of statements for Java, a character offset for Kotlin — so this exposes only what callers can ask language-independently.

  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a variable name based on the given one that is not already taken in the scope being inserted into.
    boolean
    Whether this position comes after the given one in the same scope.
  • Method Details

    • getFreeVariableName

      String getFreeVariableName(String baseName)
      Returns a variable name based on the given one that is not already taken in the scope being inserted into.
      Parameters:
      baseName - the desired name
      Returns:
      a name that is free in this scope
    • isAfter

      boolean isAfter(InsertionRef other)
      Whether this position comes after the given one in the same scope. Used to keep a component's creation ahead of its use.

      Returns false when the two are in different scopes, which is indistinguishable from "before" through this method.

      Parameters:
      other - the position to compare against
      Returns:
      true if this position is in the same scope and later