Class LineReplacement

java.lang.Object
uno.anahata.asi.toolkit.resources.text.lines.AbstractLineEdit
uno.anahata.asi.toolkit.resources.text.lines.LineReplacement

public class LineReplacement extends AbstractLineEdit
VISUAL TARGET REPLACEMENT: Replaces a range of lines with new content.

Use this when you can clearly see the start and end of a block (like a method or Javadoc) in the RAG message.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private String
    The new content for the target range.
    private int
    The 1-based line number of the resource in the RAG message where the replacement ends (Inclusive).
    private int
    The 1-based line number of the resource in the RAG message where the replacement starts (Inclusive).

    Fields inherited from class AbstractLineEdit

    reason
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    apply(List<String> lines)
    Applies this edit to a mutable list of lines.
    int
    Returns the 1-based line number where this operation starts.

    Methods inherited from class Object

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

    • startLine

      private int startLine
      The 1-based line number of the resource in the RAG message where the replacement starts (Inclusive).
    • endLine

      private int endLine
      The 1-based line number of the resource in the RAG message where the replacement ends (Inclusive).
    • content

      private String content
      The new content for the target range.

      This can contain any number of lines. Implementation details: Trailing newlines are processed structurally to ensure proper absorption.

  • Constructor Details

    • LineReplacement

      public LineReplacement()
  • Method Details

    • apply

      public void apply(List<String> lines) throws AgiToolException
      Applies this edit to a mutable list of lines.

      Performs range validation before removing the target lines and splicing in the new content.

      Specified by:
      apply in class AbstractLineEdit
      Parameters:
      lines - The current lines of the file.
      Throws:
      AgiToolException - if indices are out of bounds or validation fails.
    • getSortLine

      public int getSortLine()
      Returns the 1-based line number where this operation starts. Used for sorting updates before application.

      Returns the start line of the replacement range for sorting.

      Specified by:
      getSortLine in class AbstractLineEdit
      Returns:
      the start line.