ui: overlay diagnostic spans on the input field (ADR-0027 §2)
render_input_runs now overlays the walker's schema-aware diagnostics: an unknown table/column ERROR is recoloured tok_error, an expression WARNING (type mismatch, = NULL, LIKE on a numeric column) recoloured theme.warning. New overlay_span covers a token's whole byte range (overlay_error only hits the run at a single byte). New walker::input_diagnostics is the shared entry point. The overlay is global — every flagged token is coloured wherever it sits, not only under the cursor — which is exactly ADR-0027's motivation. The existing cursor-local invalid-ident overlay is kept (it covers in-progress idents diagnostics do not); the two are additive and idempotent. 5 input_render tests (unknown table/column, type-mismatch literal precise, LIKE-on-numeric, clean command). 1113 passing, clippy clean.
This commit is contained in:
@@ -332,6 +332,34 @@ pub fn input_verdict(
|
||||
outcome_severity.into_iter().chain(diag_severity).max()
|
||||
}
|
||||
|
||||
/// The schema-aware diagnostics for `source` (ADR-0027 §2).
|
||||
///
|
||||
/// Schema-existence ERRORs (unknown table / column) and
|
||||
/// expression WARNINGs. The highlight overlay and the hint
|
||||
/// panel both read these for *where* and *why*; the indicator
|
||||
/// ([`input_verdict`]) is the severity summary over them.
|
||||
///
|
||||
/// Empty for empty input, an unrecognised command, or a parse
|
||||
/// that never reached a structural `Match` — a parse failure
|
||||
/// carries its own ERROR through the outcome, not through a
|
||||
/// `Diagnostic`, and is highlighted by the existing
|
||||
/// definite-error path.
|
||||
#[must_use]
|
||||
pub fn input_diagnostics(
|
||||
source: &str,
|
||||
schema: Option<&crate::completion::SchemaCache>,
|
||||
) -> Vec<outcome::Diagnostic> {
|
||||
if source.trim().is_empty() {
|
||||
return Vec::new();
|
||||
}
|
||||
let mut ctx = schema.map_or_else(
|
||||
context::WalkContext::new,
|
||||
context::WalkContext::with_schema,
|
||||
);
|
||||
let (result, _cmd) = walk(source, outcome::WalkBound::EndOfInput, &mut ctx);
|
||||
result.map_or_else(Vec::new, |r| r.diagnostics)
|
||||
}
|
||||
|
||||
/// Schema-existence diagnostics (ADR-0027 §2).
|
||||
///
|
||||
/// A matched `IdentSource::Tables` token whose name is not in
|
||||
|
||||
Reference in New Issue
Block a user