Expand description
LSP feature logic for Snowflake SQL: formatting edits, parse diagnostics, and semantic tokens.
This module is deliberately transport-free (it never touches stdio or an lsp-server
connection), so every feature is a pure &str -> data function that is unit-testable. The
binary ([crate::main]) is the thin adapter that wires these into a language server.
Positions follow the LSP convention: zero-based lines and UTF-16 column offsets.
Structs§
Functions§
- apply_
change - Apply one
textDocument/didChangecontent change totext, returning the new document. - diagnostics
- Diagnostics for
textDocument/publishDiagnostics: both lexer and parser errors. Neither stage ever fails, so this is the set of recovered errors (empty for clean input). - folding_
ranges - Folding ranges for
textDocument/foldingRange: one region per multi-line top-level statement, so an editor can collapse each statement in a script. The CST’s root children are the statements. - format_
edits - The edits to apply for
textDocument/formatting: a single whole-document replacement, or an empty list when the input is already formatted (so the editor records no change). - hover
- Hover information for
textDocument/hover: the keyword/type/symbol description atposition, rendered as Markdown with an optional docs link, scoped to the hovered token’s range. - semantic_
tokens - The delta-encoded semantic tokens for
textDocument/semanticTokens/full. - token_
modifiers - The semantic-token modifier legend, mirrored from
semantic::SemanticTokenModifiers::LEGEND. A token’stoken_modifiers_bitsetis decoded bit-by-bit against this slice, so it too must match the highlighter. - token_
types - The semantic-token type legend, mirrored from the single source of truth in
sql-dialect-fmt-highlight(semantic::SemanticTokenType::LEGEND). A token’stoken_typefield is an index into this slice, so the order here is the contract with the editor (declared in the server’s capabilities) and must equal the highlighter’s legend — otherwise an editor would decode our token types against the wrong names.