Walker: node-attached HintMode via Node::Hinted (ADR-0024 §HintMode-per-node)
Replaces the hint resolver's signature-matching (does the expected set
contain all five literal forms? an Ident{NewName}?) with a grammar-
declared annotation. New Node::Hinted { mode, inner } wrapper; the
walker records the mode in WalkContext::pending_hint_mode on entry and
clears it on any successful match (cursor moved past the slot — this
also undoes the leak where a failed Hinted branch of a Choice would
otherwise strand a stale mode). The resolver reads pending_hint_mode
directly.
Value-literal fallback slots carry ProseOnly; NewName ident slots carry
ForceProse. hint_mode_at_input_inner now delegates to
hint_resolution_at_input — one resolution path, no duplicated logic.
No behaviour change; the typing-surface matrix guards it.
This commit is contained in:
@@ -7,7 +7,8 @@
|
||||
|
||||
use crate::completion::TableColumn;
|
||||
use crate::dsl::grammar::{
|
||||
IdentSource, IdentValidator, Node, NumberValidator, ValidationError, Word,
|
||||
HintMode, IdentSource, IdentValidator, Node, NumberValidator,
|
||||
ValidationError, Word,
|
||||
};
|
||||
use crate::dsl::types::Type;
|
||||
use crate::dsl::walker::context::WalkContext;
|
||||
@@ -347,7 +348,16 @@ const FALLBACK_VALUE_LITERAL_CHOICES: &[Node] = &[
|
||||
Node::NumberLit { validator: None },
|
||||
Node::StringLit,
|
||||
];
|
||||
const FALLBACK_VALUE_LITERAL: Node = Node::Choice(FALLBACK_VALUE_LITERAL_CHOICES);
|
||||
const FALLBACK_VALUE_LITERAL_INNER: Node = Node::Choice(FALLBACK_VALUE_LITERAL_CHOICES);
|
||||
/// The schemaless value-literal slot. The `ProseOnly` HintMode
|
||||
/// (ADR-0024 §HintMode-per-node) tells the hint resolver to
|
||||
/// surface the generic "Type a value: number, 'text', …" prose
|
||||
/// here rather than the misleading `null`/`true`/`false`
|
||||
/// candidate trio.
|
||||
const FALLBACK_VALUE_LITERAL: Node = Node::Hinted {
|
||||
mode: HintMode::ProseOnly("hint.value_literal_slot"),
|
||||
inner: &FALLBACK_VALUE_LITERAL_INNER,
|
||||
};
|
||||
|
||||
const FALLBACK_VALUE_LIST: Node = Node::Repeated {
|
||||
inner: &FALLBACK_VALUE_LITERAL,
|
||||
@@ -434,10 +444,3 @@ pub fn column_value_list(ctx: &WalkContext) -> Node {
|
||||
}
|
||||
Node::Seq(Box::leak(children.into_boxed_slice()))
|
||||
}
|
||||
|
||||
// The HintMode / NumberValidator imports are part of the Phase D
|
||||
// typed-slot toolkit even though only NumberValidator is used by
|
||||
// the explicit validators above; surface HintMode so future
|
||||
// per-type prose annotations can attach without re-importing.
|
||||
#[allow(dead_code)]
|
||||
const _USES_HINT_MODE: Option<crate::dsl::grammar::HintMode> = None;
|
||||
|
||||
Reference in New Issue
Block a user