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:
+57
-13
@@ -49,32 +49,76 @@ pub enum HighlightClass {
|
||||
|
||||
/// Where an `Ident` slot's candidates come from at completion time.
|
||||
///
|
||||
/// Phase A only exercises `NewName` (the `import … as <target>`
|
||||
/// slot) and `Free` (the catch-all branch in `mode`/`messages`
|
||||
/// that funnels unknown values into a friendly validator). The
|
||||
/// schema-aware variants land in Phase B-D.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
/// Drives both the walker's `Expectation::Ident { source }` (which
|
||||
/// the parse-error bridge maps to a human label) and the
|
||||
/// `SchemaCache` lookup the completion engine uses for Tab
|
||||
/// candidates. The `Free` and `NewName` variants do not query the
|
||||
/// schema — `NewName` is for slots where the user invents the
|
||||
/// identifier, `Free` is the catch-all branch in `mode`/`messages`
|
||||
/// that funnels unknown values into a friendly validator.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub enum IdentSource {
|
||||
/// User invents this name. No schema lookup; no completion
|
||||
/// candidates beyond the identifier shape itself.
|
||||
NewName,
|
||||
/// Existing table name. Phase B+.
|
||||
#[allow(dead_code)]
|
||||
/// Existing table name.
|
||||
Tables,
|
||||
/// Existing column in the current table. Phase B+.
|
||||
#[allow(dead_code)]
|
||||
/// Existing column in the current table.
|
||||
Columns,
|
||||
/// Existing relationship name. Phase B+.
|
||||
#[allow(dead_code)]
|
||||
/// Existing relationship name.
|
||||
Relationships,
|
||||
/// Closed set from `Type::all()`. Phase B+.
|
||||
#[allow(dead_code)]
|
||||
/// Closed set from `Type::all()` — surfaced by the walker's
|
||||
/// content validator on column-type slots; not user-listable
|
||||
/// from the schema.
|
||||
Types,
|
||||
/// Any identifier shape; used by synthetic catch-all branches
|
||||
/// (e.g., the unknown-value branch of `mode <value>`).
|
||||
Free,
|
||||
}
|
||||
|
||||
impl IdentSource {
|
||||
/// Whether this source can be completed from the schema
|
||||
/// cache (i.e. the candidate list comes from existing
|
||||
/// entities rather than user invention or a closed set).
|
||||
#[must_use]
|
||||
pub const fn completes_from_schema(self) -> bool {
|
||||
matches!(self, Self::Tables | Self::Columns | Self::Relationships)
|
||||
}
|
||||
|
||||
/// Human-facing label used in parse-error wording
|
||||
/// ("expected table name") and in the completion engine's
|
||||
/// round-trip from a textual `expected` entry back to a
|
||||
/// source kind. `Free` and `Types` collapse to "identifier"
|
||||
/// and "type" respectively.
|
||||
#[must_use]
|
||||
pub const fn expected_label(self) -> &'static str {
|
||||
match self {
|
||||
Self::NewName | Self::Free => "identifier",
|
||||
Self::Tables => "table name",
|
||||
Self::Columns => "column name",
|
||||
Self::Relationships => "relationship name",
|
||||
Self::Types => "type",
|
||||
}
|
||||
}
|
||||
|
||||
/// Inverse of `expected_label`. Used by the completion engine
|
||||
/// to recover the source kind from the `ParseError::Invalid::
|
||||
/// expected` strings the walker bridge produces. `"identifier"`
|
||||
/// maps to `NewName` (the only writeable label that uses that
|
||||
/// wording in production grammars today).
|
||||
#[must_use]
|
||||
pub fn from_expected_label(label: &str) -> Option<Self> {
|
||||
match label {
|
||||
"identifier" => Some(Self::NewName),
|
||||
"table name" => Some(Self::Tables),
|
||||
"column name" => Some(Self::Columns),
|
||||
"relationship name" => Some(Self::Relationships),
|
||||
"type" => Some(Self::Types),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Hint-panel mode for an expected node.
|
||||
///
|
||||
/// Phase A defaults to `Default`; the `ProseOnly` variant
|
||||
|
||||
Reference in New Issue
Block a user