Skip to content

Incremental re-parse, snapshot structural sharing, and structural diff #61

@konard

Description

@konard

Context

Issue #47's title demands "the richest features set". The competitor survey
(competitors-code-tooling.md) ranks
incremental re-parse with subtree reuse (tree-sitter) and red/green persistent
trees with structure sharing (Roslyn, rowan/Biome) as the top capabilities
meta-language lacks; difftastic adds structural snapshot diffing. Today every
edit re-parses from scratch. See
solution-plans.md S-13.

Scope

  • Expose tree-sitter's native incremental parsing (InputEdit + previous
    tree) through src/tree_sitter_adapter.rs:
    LinkNetwork::apply_edit(range, new_text) re-parses only affected regions;
    link ids outside the edited span stay stable.
  • Extend NetworkSnapshot so an edited fork shares unchanged links with its
    parent (rowan/cstree precedent), with a test measuring sharing.
  • Structural diff between two snapshots returning changed/added/removed link
    sets (difftastic precedent) - this also gives transforms a cheap dry-run
    preview.

Acceptance criteria

  • apply_edit produces a network equal to a from-scratch parse of the
    edited text (byte-exact reconstruction) while preserving ids outside
    the edit.
  • Snapshot fork sharing is asserted (unchanged links are not duplicated).
  • Structural diff is tested on an edit fixture and exposed publicly.
  • Changelog fragment added (bump: minor).

References


Filed from docs/case-studies/issue-47/proposed-issues/13-incremental-reparse-structural-sharing.md. Part of the implementation plan for #47.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions