ADR-0024 Phase F (full) step 3: delete legacy parser modules
Removes the last consumers of `dsl::lexer`, `dsl::keyword`, and
`dsl::ident_slot`, then deletes the modules.
- `Theme::token_color(&TokenKind)` deleted along with its test;
`Theme::highlight_class_color(HighlightClass)` is the sole
highlight-colour mapper (the walker's `per_byte_class` feeds
it directly).
- `IdentSource` (`dsl::grammar`) absorbs the schema-list /
expected-label / round-trip semantics that previously lived
on `IdentSlot`. Adds `completes_from_schema`, `expected_label`,
and `from_expected_label` methods. The walker's
`Expectation::Ident { source }` and the schema-lookup request
on the database worker now share one enum.
- `SchemaCache::for_slot(IdentSlot)` → `for_source(IdentSource)`.
- `Database::list_names_for` and the `Request::ListNamesFor`
worker variant take `IdentSource`. Internal tables and column
/ relationship lookups dispatch on the same enum.
- `InvalidIdent.slot: IdentSlot` → `InvalidIdent.source: IdentSource`.
The `invalid_ident_at_cursor` rendering branch in
`input_render.rs::ambient_hint` updates accordingly.
- Completion's keyword filter (`Keyword::from_word`) becomes
"backticked items whose payload is all ASCII alphabetic" —
punct and digit literals still surface through their own
candidate sources (composite-literal, flag, schema-ident);
the alphabetic filter excludes them from the keyword bucket.
- `friendly::keys::tests::keyword_and_punct_have_complete_token_vocabulary`
is dropped. It cross-checked `Keyword::ALL` / `Punct::ALL`
against catalog entries; both enums are gone. The
`parse.token.keyword.*` / `parse.token.punct.*` catalog
entries themselves survive for one more commit (catalog
cleanup, ADR-0024 §cleanup-pass); the
`keys_validate_against_catalog` test still pins them.
- Modules deleted: `src/dsl/lexer.rs`, `src/dsl/keyword.rs`,
`src/dsl/ident_slot.rs`.
Tests: 806 passing, 0 failing, 1 ignored. The drop from 852
reflects the removed module-internal tests (~32 lexer, 7
keyword, 4 ident_slot, 1 theme token_color, 1 friendly keys
keyword/punct), and is the expected outcome.
Clippy clean with `nursery` lints + `-D warnings`.
This commit is contained in:
+8
-64
@@ -19,7 +19,6 @@
|
||||
use ratatui::style::Color;
|
||||
|
||||
use crate::dsl::grammar::HighlightClass;
|
||||
use crate::dsl::lexer::TokenKind;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum Background {
|
||||
@@ -106,23 +105,6 @@ impl Theme {
|
||||
}
|
||||
}
|
||||
|
||||
/// Map a `TokenKind` to its display colour for ambient
|
||||
/// highlighting (ADR-0022 §3). Lex-error tokens always render
|
||||
/// in `tok_error`, regardless of the parse-time error overlay
|
||||
/// applied separately by the renderer.
|
||||
#[must_use]
|
||||
pub const fn token_color(&self, kind: &TokenKind) -> Color {
|
||||
match kind {
|
||||
TokenKind::Keyword(_) => self.tok_keyword,
|
||||
TokenKind::Identifier(_) => self.tok_identifier,
|
||||
TokenKind::Number(_) => self.tok_number,
|
||||
TokenKind::StringLiteral(_) => self.tok_string,
|
||||
TokenKind::Punct(_) => self.tok_punct,
|
||||
TokenKind::Flag(_) => self.tok_flag,
|
||||
TokenKind::Error(_) => self.tok_error,
|
||||
}
|
||||
}
|
||||
|
||||
/// Map a walker `HighlightClass` to its display colour
|
||||
/// (ADR-0024 §architecture, Phase F). This is the walker-side
|
||||
/// equivalent of `token_color` — the renderer consumes
|
||||
@@ -152,8 +134,6 @@ impl Default for Theme {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::dsl::keyword::{Keyword, Punct};
|
||||
use crate::dsl::lexer::LexError;
|
||||
|
||||
#[test]
|
||||
fn dark_theme_token_colours_differ_from_background() {
|
||||
@@ -190,50 +170,14 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn token_color_maps_each_kind_to_the_expected_field() {
|
||||
fn highlight_class_color_maps_each_variant() {
|
||||
let t = Theme::dark();
|
||||
assert_eq!(
|
||||
t.token_color(&TokenKind::Keyword(Keyword::Create)),
|
||||
t.tok_keyword,
|
||||
);
|
||||
assert_eq!(
|
||||
t.token_color(&TokenKind::Identifier("Customers".to_string())),
|
||||
t.tok_identifier,
|
||||
);
|
||||
assert_eq!(
|
||||
t.token_color(&TokenKind::Number("42".to_string())),
|
||||
t.tok_number,
|
||||
);
|
||||
assert_eq!(
|
||||
t.token_color(&TokenKind::StringLiteral("hi".to_string())),
|
||||
t.tok_string,
|
||||
);
|
||||
assert_eq!(
|
||||
t.token_color(&TokenKind::Punct(Punct::Colon)),
|
||||
t.tok_punct,
|
||||
);
|
||||
assert_eq!(
|
||||
t.token_color(&TokenKind::Flag("all-rows".to_string())),
|
||||
t.tok_flag,
|
||||
);
|
||||
assert_eq!(
|
||||
t.token_color(&TokenKind::Error(LexError::UnknownChar('$'))),
|
||||
t.tok_error,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lex_error_tokens_render_in_tok_error_regardless_of_kind() {
|
||||
let t = Theme::dark();
|
||||
for err in [
|
||||
LexError::UnknownChar('$'),
|
||||
LexError::UnterminatedString,
|
||||
LexError::BadFlag,
|
||||
] {
|
||||
assert_eq!(
|
||||
t.token_color(&TokenKind::Error(err)),
|
||||
t.tok_error,
|
||||
);
|
||||
}
|
||||
assert_eq!(t.highlight_class_color(HighlightClass::Keyword), t.tok_keyword);
|
||||
assert_eq!(t.highlight_class_color(HighlightClass::Identifier), t.tok_identifier);
|
||||
assert_eq!(t.highlight_class_color(HighlightClass::Number), t.tok_number);
|
||||
assert_eq!(t.highlight_class_color(HighlightClass::String), t.tok_string);
|
||||
assert_eq!(t.highlight_class_color(HighlightClass::Punct), t.tok_punct);
|
||||
assert_eq!(t.highlight_class_color(HighlightClass::Flag), t.tok_flag);
|
||||
assert_eq!(t.highlight_class_color(HighlightClass::Error), t.tok_error);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user