Skip to main content

Module diff

Module diff 

Source

Modules§

apted
Tree-edit-distance computation, split across three files: common (shared infrastructure - cost model, indexing, delta/forest-distance tables, the backtrace that turns a populated delta table into an ASTDiff, and the public entry points), zhang_shasha (the classic Zhang-Shasha algorithm), and engine (the APTED algorithm: gted/spfL/spfR/spfA plus optimal-strategy computation).
cost
nodes
solve_bottom_up_expansion
solve_comment_nodes
solve_greedy_anchor_blocks
solve_hash_descent
solve_identical_diagnostic_statements
solve_large_flat_subtrees
solve_moved_subtrees
MoveDetectionRecovery: the final pass of the pipeline, running after the tree-edit-distance step has fully decided the diff. Scans what got wholly deleted and wholly inserted and pairs up byte-identical subtrees between the two sets - code that didn’t change but moved, which plain ordered tree edit distance structurally cannot express as anything but delete+insert whenever the move crosses a matched boundary (the classic case: a subtree relocating into a newly-inserted wrapper, or into a container whose own identity changed - see the rust-turbopack-module-rule analysis in TODO.md).
solve_similar_flow_control
solve_syntax_aware_matching
text
text_range

Structs§

ASTDiff
Difference between two Code structures, based on their TreeSitter ASTs.
ASTMapping
Information about the mapping of two AST subtrees.
Diff
The main data structure. Contains the difference between two Code structures.
HeuristicConfig
Per-pass on/off switches for Diff::from_code_with_config’s seven-phase pipeline, for the passes whose accuracy contribution is ambiguous enough to be worth re-measuring independently. HeuristicConfig::default is what plain Diff::from_code/diff_code use, and is the only configuration any production caller should need.
NodeCache
A structure that holds node caches for both before and after Code objects.
PendingDiff
Phases 1-5 of the seven-phase pipeline (see Diff::from_code_with_config), paused immediately before phase 6 so a caller can inspect PendingDiff::looks_expensive and choose a DiffMode before running (or skipping) full tree-edit-distance. PendingDiff::finish runs phases 6-7 and assembles the final Diff.

Enums§

ASTMappingOperation
The operations that can be used to transform one tree into another.
ASTMappingReason
Why were the two subtrees mapped to each other?
DiffMode
Controls how PendingDiff::finish runs phase 6 (final whole-tree APTED).

Constants§

COST_DELETE
COST_INSERT
COST_MOVE
COST_UPDATE
EXPENSIVE_RESIDUAL_THRESHOLD
Guard threshold consulted by PendingDiff::looks_expensive: if the larger of unmatched_before/unmatched_after (node counts still unmapped after phase 5) exceeds this, DiffMode::Fast substitutes apted::for_roots_fallback for phase 6 instead of full APTED.

Functions§

diff_code
Creates a Diff from two Code objects.
diff_code_with_config
Same as diff_code, but forwards config to Diff::from_code_with_config - see that function and HeuristicConfig for what it’s for.