Struct ReduceCx
pub struct ReduceCx<'a> { /* private fields */ }Expand description
The arena/token context handed to a ReduceCallback::reduce call. Both
engines build one over their live child arena + token arena, so the hook
resolves NodeValue::Token(idx) leaves and constructs arena-backed
NodeValue::Trees (the representation a _-splice parent can drain) without
engine-specific glue.
Implementations§
§impl<'a> ReduceCx<'a>
impl<'a> ReduceCx<'a>
pub fn new( arena: &'a mut Vec<NodeValue>, tokens: &'a [Token], metas: &'a [Meta], ) -> Self
pub fn take_span_plan(&mut self) -> Option<PendingSpan>
pub fn take_span_plan(&mut self) -> Option<PendingSpan>
The reduce’s RAW pre-filter span plan — Some only under
propagate_positions in transform mode. A batching hook takes it at
enqueue and resolves/stamps at its drain (lark’s PropagatePositions
semantics); leaving it means the engine stamps the returned value
itself (Tree results only).
pub fn token(&self, idx: TokenArenaIdx) -> &Token
pub fn token(&self, idx: TokenArenaIdx) -> &Token
Resolve a NodeValue::Token(idx) leaf to its Token (a binding
materializes its host token type from this). idx/tree here (and in
Self::tree_children/Self::tree_meta) must come from an
engine-produced NodeValue; an out-of-range index panics — engine-
invariant, the same tier as the ParsedTree accessors.
pub fn tree_children(&self, tree: &Tree) -> &[NodeValue]
pub fn tree_children(&self, tree: &Tree) -> &[NodeValue]
Read a NodeValue::Tree’s children out of the arena (a binding walks a
sub-result it did not itself build).
pub fn tree_meta(&self, tree: &Tree) -> Option<&Meta>
pub fn tree_meta(&self, tree: &Tree) -> Option<&Meta>
A Tree’s position Meta, when one was computed (propagate_positions
on and the node stamped). None for MetaIdx::NONE.
pub fn build_tree(
&mut self,
data_id: DisplayId,
children: Vec<NodeValue>,
) -> NodeValue
pub fn build_tree( &mut self, data_id: DisplayId, children: Vec<NodeValue>, ) -> NodeValue
Build an arena-backed Tree(data_id, children) (meta == MetaIdx::NONE; the
engine attaches position meta to the returned node afterward under
propagate_positions). This is the drainable default a _-splice parent
inlines via child.children.