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§
- diagnose
- Parse
textas SQL and return diagnostics for any parse errors and variable issues.