2g: advanced-mode highlight + engine.* wiring + matrix tests

Cross-cut verification matrix for ADR-0032 Phase 2 is now fully
populated with concrete test references — every row green. Filling
the matrix surfaced three real gaps that this commit closes.

1. Advanced-mode syntax highlighting (ADR-0030 §8 matrix row).
   The `ui.rs` Advanced branch routed through `plain_input_spans`,
   bypassing the highlight walker entirely. In production SQL
   keywords past the entry word rendered as plain identifiers.
   Fix: mode-aware variants of `highlight_runs`,
   `render_input_runs`, `lex_to_runs`, and `input_diagnostics`;
   the Advanced render path now uses the highlighted form with
   `Mode::Advanced`. `plain_input_spans` removed (unused).

2. Engine.* key wiring (ADR-0032 §11.4 / §13 matrix rows + handoff
   §3.3 follow-up). The four Phase-2 engine.* catalog entries
   were authored in 2d but never reached: `translate_generic`
   discarded the engine message and returned a vague catalog
   entry. Fix: pattern-match the engine message text for the four
   Phase-2 categories (aggregate misuse, group-by required,
   compound arity mismatch fallback, scalar-subquery cardinality)
   inside `translate_generic`, routing each to its engine-neutral
   catalog entry.

3. Matrix-coverage tests. Thirteen new tests covering the rows
   that had no explicit coverage:
   - 3 SQL keyword/operator/CASE highlight tests
   - 4 engine.* engine-message tests
   - 3 sql_expr column-completion tests (WHERE, HAVING)
   - 3 predicate-warning slot tests (CASE, ORDER BY, projection)
   - 1 all-10-playground-types recovery test (tests/sql_select.rs)

Plan document (docs/plans/20260520-adr-0032-phase-2.md) updated:
every (TBD) row in the cross-cut matrix replaced with a concrete
test file::function reference and a green status marker.

Test totals: 1428 → 1441 passing (+13 new). Clippy clean.
This commit is contained in:
claude@clouddev1
2026-05-20 21:38:08 +00:00
parent ee0dafd86b
commit ed881eea59
8 changed files with 456 additions and 96 deletions
+29
View File
@@ -2138,6 +2138,35 @@ mod tests {
assert!(cs.contains(&"total".to_string()));
}
#[test]
fn sql_expr_column_completion_inside_where() {
// ADR-0031 §5 — column completion works for
// IdentSource::Columns slots inside SQL expressions.
// At `select * from a where i|`, the partial prefix `i`
// walks `where`'s sql_expr, expects an Ident{Columns},
// and offers `id` (a's column starting with `i`).
let cache = two_table_schema();
let input = "select * from a where i";
let cursor = input.len();
let cs = cands_with(input, cursor, &cache);
assert!(
cs.contains(&"id".to_string()),
"expected `id` candidate via sql_expr WHERE column slot; got {cs:?}",
);
}
#[test]
fn sql_expr_column_completion_inside_having() {
let cache = two_table_schema();
let input = "select * from a group by id having n";
let cursor = input.len();
let cs = cands_with(input, cursor, &cache);
assert!(
cs.contains(&"name".to_string()),
"expected `name` candidate via sql_expr HAVING column slot; got {cs:?}",
);
}
#[test]
fn lookahead_with_partial_prefix_filters_correctly() {
// `select na| from a` — narrowing via look-ahead +