Skip to main content

Crate sql_dialect_fmt_lsp

Crate sql_dialect_fmt_lsp 

Source
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§

LintOptions
Lint knobs. Every rule is on by default; each can be disabled independently.

Enums§

LintCode
The stable identity of a lint rule; rendered as SDFxxx via LintCode::as_str.
PositionEncoding
LSP position encoding negotiated with the client.

Functions§

apply_change
Apply one textDocument/didChange content change to text, 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
The LintCode carried by an LSP diagnostic, when it is one of ours.
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 at position, rendered as Markdown with an optional docs link, scoped to the hovered token’s range.
hover_with_encoding
Encoding-aware variant of hover.
on_type_formatting_edits
The edits to apply for textDocument/onTypeFormatting: after the user types ; or a newline, reformat the statement that just ended.
on_type_formatting_edits_with_encoding
Encoding-aware variant of on_type_formatting_edits.
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’s token_modifiers_bitset is 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’s token_type field 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.