Expand description
LSP feature logic for Snowflake SQL: formatting, diagnostics, hover, folding, document symbols, completion, 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 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§
- Lint
Options - LSP-only lint knobs layered on top of parser diagnostics.
Enums§
- Lint
Code - Position
Encoding - LSP position encoding negotiated with the client.
Functions§
- apply_
change - Apply one
textDocument/didChangecontent change totext, returning the new document. - apply_
change_ with_ encoding - Encoding-aware variant of
apply_change. - completion_
items - Static SQL completion items for
textDocument/completion. - diagnostic_
lint_ code - 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). - diagnostics_
with_ encoding - Encoding-aware variant of
diagnostics. - diagnostics_
with_ lint_ options - Options-, lint-, and encoding-aware variant of
diagnostics. - diagnostics_
with_ options - Options- and encoding-aware variant of
diagnostics. - document_
symbols - Document symbols for
textDocument/documentSymbol: one outline item per top-level statement. - document_
symbols_ with_ encoding - Encoding-aware variant of
document_symbols. - 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). - format_
edits_ with_ encoding - Encoding-aware variant of
format_edits. - format_
range_ edits - The edits to apply for
textDocument/rangeFormatting: reformat only the statements the range touches, as one minimal replacement, or an empty list when nothing changes. - format_
range_ edits_ with_ encoding - Encoding-aware variant of
format_range_edits. - 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. - hover_
with_ encoding - Encoding-aware variant of
hover. - semantic_
tokens - The delta-encoded semantic tokens for
textDocument/semanticTokens/full. - semantic_
tokens_ range_ with_ encoding - The delta-encoded semantic tokens that intersect
range. - semantic_
tokens_ with_ encoding - Encoding-aware variant of
semantic_tokens. - 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.