Skip to main content

Module api

Module api 

Source
Expand description

Incremental re-lex API for LSP textDocument/didChange events.

§Overview

parse_incremental_change takes the old token stream and the already-applied new source string, re-lexes only the “dirty” region (the changed portion plus tokens that straddle the edit boundary), splices the result into the stream, and shifts all post-edit token positions by the byte delta.

§Position model

The Lexer tracks positions as char indices (indices into Vec<char>), not raw byte offsets. TextChange.range similarly operates in char-index space (i.e. “number of Unicode scalar values from the start of the source”). All offset arithmetic below is therefore in char-index units; conversion to byte offsets is only needed when slicing the UTF-8 source string.

Structs§

IncrementalChangeResult
The result of an incremental re-lex triggered by a single text edit.

Functions§

parse_incremental_change
Incrementally re-lex a single text edit.