Class InsertionPoint

java.lang.Object
com.vaadin.copilot.javarewriter.InsertionPoint

public class InsertionPoint extends Object
Represents a point in the source code where new code can be inserted.
  • Constructor Summary

    Constructors
    Constructor
    Description
    InsertionPoint(com.github.javaparser.ast.body.ClassOrInterfaceDeclaration declaration, int index)
     
    InsertionPoint(com.github.javaparser.ast.stmt.BlockStmt block, int index)
    Creates a new InsertionPoint instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(com.github.javaparser.ast.stmt.Statement statement)
    Adds a statement to the insertion point.
    com.github.javaparser.ast.stmt.BlockStmt
     
    com.github.javaparser.ast.CompilationUnit
     
    com.github.javaparser.ast.body.ClassOrInterfaceDeclaration
     
    Returns a free variable name based on the given base name, available in the scope where code will be inserted.
    int
     
    void
    incrementIndex(int increment)
    Increment index by given amount
    void
    Increment index by adding 1
    boolean
    isAfter(InsertionPoint referenceLocation)
    Checks if this location is inside the same block as the reference location but after it.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • InsertionPoint

      public InsertionPoint(com.github.javaparser.ast.stmt.BlockStmt block, int index)
      Creates a new InsertionPoint instance.
      Parameters:
      block - the block where to insert the code
      index - the index where to insert the code
    • InsertionPoint

      public InsertionPoint(com.github.javaparser.ast.body.ClassOrInterfaceDeclaration declaration, int index)
  • Method Details

    • getFreeVariableName

      public String getFreeVariableName(String baseName)
      Returns a free variable name based on the given base name, available in the scope where code will be inserted.
      Parameters:
      baseName - the base name for the variable
      Returns:
      a free variable name
    • add

      public void add(com.github.javaparser.ast.stmt.Statement statement)
      Adds a statement to the insertion point.
      Parameters:
      statement - the statement to add
    • incrementIndex

      public void incrementIndex(int increment)
      Increment index by given amount
      Parameters:
      increment - value to add
    • incrementIndexByOne

      public void incrementIndexByOne()
      Increment index by adding 1
    • getBlock

      public com.github.javaparser.ast.stmt.BlockStmt getBlock()
    • getIndex

      public int getIndex()
    • getDeclaration

      public com.github.javaparser.ast.body.ClassOrInterfaceDeclaration getDeclaration()
    • isAfter

      public boolean isAfter(InsertionPoint referenceLocation)
      Checks if this location is inside the same block as the reference location but after it.
      Parameters:
      referenceLocation - the reference location
      Returns:
      true if this location is inside the same block as the reference location but after it, false otherwise
    • getCompilationUnit

      public com.github.javaparser.ast.CompilationUnit getCompilationUnit()