utils/diff/diff_utils library
Diff utilities for computing, formatting, and applying text diffs.
Provides line-level, word-level, and character-level diffing, patch creation/application, and semantic grouping of changes.
Classes
- ChangeBlock
- A contiguous block of related changes.
- CharDiff
- A character-level diff element.
- DiffStats
- Summary statistics for a diff.
- Hunk
- A single hunk in a patch.
- LineDiff
- A single line in a line-level diff.
- PatchResult
- Result of applying a patch.
- PatchSet
- A set of hunks that together describe a transformation.
- SemanticDiff
- Groups related diff lines into logical change blocks.
- WordDiff
- A word-level diff element.
Enums
Functions
-
applyPatch(
String text, PatchSet patch) → PatchResult -
Apply a
patchtotext, returning a PatchResult. -
computeCharDiff(
String oldStr, String newStr) → List< CharDiff> -
Compute a character-level diff between
oldStrandnewStr. -
computeLineDiff(
String oldText, String newText) → List< LineDiff> -
Compute a line-level diff between
oldTextandnewText. -
computeWordDiff(
String oldLine, String newLine) → List< WordDiff> -
Compute a word-level diff between
oldLineandnewLine. -
createPatch(
String oldText, String newText, {int contextLines = 3}) → PatchSet -
Create a PatchSet from
oldTexttonewText. -
diffStats(
String oldText, String newText) → DiffStats -
Compute DiffStats between
oldTextandnewText. -
formatPatch(
PatchSet patch) → String - Format a PatchSet as a unified diff string.
-
generateSummary(
List< LineDiff> diffs) → String - Generate a human-readable summary from a list of LineDiffs.
-
longestCommonSubsequence<
T> (List< T> a, List<T> b) → List<T> - Compute the longest common subsequence of two lists.
-
shortestEditScript<
T> (List< T> a, List<T> b) → List<EditOp> - Compute the shortest edit script (Myers' algorithm simplified).