ExAST.Diff (ExAST v0.11.0)

Copy Markdown View Source

Syntax-aware diffing for Elixir source code.

Parses two source strings with Sourceror, maps structurally similar AST nodes, and produces a diff result with insert, delete, update, and move edits.

Summary

Functions

Applies a diff result to the left source, producing the patched output.

Types

option()

@type option() :: {:include_moves, boolean()}

Functions

apply(result)

@spec apply(ExAST.Diff.Result.t()) :: String.t()

Applies a diff result to the left source, producing the patched output.

Updates and deletes are applied via range replacement. Inserts are placed at the resolved insertion point based on sibling/parent context. Move edits are skipped (content unchanged, only order differs).

diff(left_source, right_source, opts \\ [])

@spec diff(String.t(), String.t(), [option()]) :: ExAST.Diff.Result.t()

diff_files(left_path, right_path, opts \\ [])

@spec diff_files(String.t(), String.t(), [option()]) :: ExAST.Diff.Result.t()