compute_file_diff

Function compute_file_diff 

Source
pub fn compute_file_diff(
    file_id: FileId,
    old_signature: Option<&FileSignature>,
    new_signature: Option<&FileSignature>,
) -> CodebaseDiff
Expand description

Computes the difference between an old file signature and a new file signature.

This function uses the Myers diff algorithm to efficiently identify changes between two versions of a file’s AST. Unlike Hakana which differentiates between signature and body changes, we use a single hash approach: any change triggers re-analysis.

§Arguments

  • file_id - The identifier of the file being compared (used for diff_map)
  • old_signature - The previous file signature (None if this is a new file)
  • new_signature - The current file signature

§Returns

A CodebaseDiff containing:

  • keep: Symbols that are unchanged
  • changed: Symbols that are new, deleted, or modified
  • diff_map: Position mappings for symbols that moved
  • deletion_ranges_map: Ranges of deleted code