Class LLMDiffs

java.lang.Object
io.codemodder.plugins.llm.LLMDiffs

public final class LLMDiffs extends Object
Utilities for working with diff patches returned by an LLM.
  • Method Details

    • applyDiff

      public static List<String> applyDiff(List<String> target, String diff)
      Applies a diff in unified format to target.

      If the LLM was handed code with unusual indentation, it can struggle to create a diff patch with that indentation preserved. This will attempt to fix the indentation of the original lines in the diff patch before passing it to UnifiedDiffUtils for parsing.

      Parameters:
      target - The target.
      diff - The diff.
      Returns:
      The patched target.
      Throws:
      IllegalArgumentException - If the diff cannot be applied to target.