Skip to main content

Module incremental_parse

Module incremental_parse 

Source
Expand description

Incremental parsing support for tree-sitter.

This module provides utilities for incremental AST parsing using tree-sitter’s InputEdit API. When a file changes, instead of re-parsing from scratch, tree-sitter can reuse unchanged portions of the old parse tree.

§Architecture

  • InputEditCalculator: Calculates byte/line/column edits between file versions
  • TreeCache: LRU cache storing recently parsed trees for reuse
  • IncrementalParser: High-level wrapper coordinating incremental parsing

§Performance

Incremental parsing typically provides 5-10x speedup for small edits compared to full re-parsing, as tree-sitter reuses unchanged AST subtrees.

Structs§

IncrementalParser
High-level incremental parser coordinating tree caching and re-parsing.
InputEditCalculator
Calculates InputEdit describing changes between two file versions.
TreeCache
LRU cache for parsed trees to enable incremental parsing.