Expand description
Source-positioned diagnostics decoupled from any output format.
PositionalDiagnostic is the neutral intermediate representation: a
severity, a file path, a source string, and a byte range within that
source. The LSP server wraps it into tower_lsp::lsp_types::Diagnostic
by converting the byte range to line/column via a ropey::Rope; the CLI
wraps it into an annotate_snippets snippet for terminal output.
Both consumers share the locator helpers in this module
(find_identifier, find_identifier_after, locate_plan,
locate_catalog, locate_typecheck, locate_validation) which
derive byte ranges from mz_sql and validation errors that carry only an
identifier name (no offset). The module also exposes
format_typecheck_kind and format_validation_kind, the shared
formatters that turn an error kind into a (message, footers, suggestions)
triple β footers carry class-level advice, suggestions carry
mechanical edits encoded as byte-range replacements.
StructsΒ§
- Positional
Diagnostic π - A diagnostic anchored to a byte range within a single source file.
- Replacement π
- A single replacement: substitute
byte_rangeof the source withreplacement. - Suggestion π
- One or more interchangeable replacements offered under a single help title. Renders as a rustc-style multi-suggestion block:
EnumsΒ§
- Severity π
FunctionsΒ§
- column_
display π - Format
table.columnas a dotted PostgreSQL reference (relation + column). Each component is rendered as its raw identifier β no outer quotes β so a reader interprets the dot as a separator rather than as part of a single quoted identifier. - fallback_
catalog π - fallback_
plan π - find_
identifier π - Find the first whole-word occurrence of
nameinsource. - find_
identifier_ πafter - Same as
find_identifierbut starts the search atstart_byte. Returns absolute byte ranges intosource. - format_
catalog π - format_
plan π - format_
typecheck_ πkind - Build the (message, footers, suggestions) triple for one typecheck kind.
- format_
validation_ πkind - Build the (message, footers, suggestions) triple for a validation kind.
- is_
ident_ πbyte - last_
component π - Strip qualifying prefixes from a dotted identifier, returning the final
component.
schema.tableβtable;tβt. - locate_
catalog π - Locate the byte range a
CatalogErrorpoints at withinsource. - locate_
plan π - Locate the byte range a
PlanErrorpoints at withinsource. - locate_
replacement π - Find the byte range of
needleto replace. - locate_
typecheck π - Locate the byte range a typecheck error points at within
source. - locate_
validation π - Locate the byte range of the declared identifier in a *Mismatch
validation error. Returns
Nonefor variants that donβt carry adeclaredname we can rewrite. - mismatch_
pair π Some((declared, expected))ifkindis a rewritable *Mismatch variant β the trailing identifier the user wrote, plus the one their file path requires.- mismatch_
suggestion π