Expand description
LSP-specific diagnostic emission.
Each producer in this module first builds a
PositionalDiagnostic using the shared locator
helpers, then converts it to a tower_lsp::lsp_types::Diagnostic via
to_lsp using a Rope for byte-offset → line/column conversion.
Three tiers of diagnostics:
-
Per-keystroke diagnostics (
diagnose()) — Resolves psql-style variables before parsing. Unresolved variables produce positioned diagnostics (ERROR or WARNING depending on the warn pragma). The resolved SQL is then parsed withmz_sql_parser::parser::parse_statements()and any parse error positions are mapped back to original-text offsets viaresolved_to_original. -
On-save validation errors (
validation_diagnostics()) — Converts project-levelValidationErrors into LSP diagnostics grouped by file. When an error carries a byte offset (most statement-level errors), the diagnostic is positioned at the correct line/column. File-level errors (e.g., missing CREATE statement) fall back to(0, 0). -
On-save typecheck errors (
typecheck_diagnostics()) — Inspects the structured upstream error to position the diagnostic. Seelocate_typecheckfor the dispatch.
Functions§
- append_
detail_ 🔒and_ hints - Append
\ndetail: <detail>(when present) and one\nhint: <footer>line per footer tomessage. Preserves the human-readable advice for editors that don’t render code actions. - attach_
quickfix_ 🔒data - Encode
suggestionsas theQuickFixDataJSON payload ondiag.datafor the LSP code-action handler. No-op whensuggestionsis empty. - build_
error_ 🔒diagnostic - Build an error-severity LSP
Diagnosticforbyte_rangeinrope. - diagnose
- Parse
textas SQL and return diagnostics for any parse errors and variable issues. - offset_
to_ 🔒position - Convert a byte offset to an LSP
Position(line, column) using aRope. - parse_
positional 🔒 - Build
PositionalDiagnostics for parse errors and unresolved variables intext. All positions are in original-text byte space (post-substitution parser offsets are mapped back viaresolved_to_original). - position_
to_ 🔒offset - Convert an LSP
Positioninto a byte offset using aRope. - read_
source 🔒 - to_lsp 🔒
- Convert a
PositionalDiagnosticto an LSPDiagnostic. - typecheck_
diagnostics 🔒 - Convert a
TypeCheckErrorinto LSP diagnostics grouped by file path. - utf16_
len 🔒 - validation_
diagnostics 🔒 - Convert
ValidationErrors into LSP diagnostics grouped by file path.