pub struct TreeContext { /* private fields */ }Expand description
External parent-tracking context for an expression tree.
Since Rust’s ownership model does not allow intrusive parent pointers in the AST,
TreeContext provides an on-demand side-table that maps each node (identified by
a NodeId) to its ParentInfo (parent node, field name, and list index).
Build a context from any expression root with TreeContext::build, then query
parent relationships with get, ancestry chains with
ancestors_of, or tree depth with
depth_of.
This is useful when analysis requires upward navigation (e.g., determining whether a column reference appears inside a WHERE clause or a JOIN condition).
Implementations§
Source§impl TreeContext
impl TreeContext
Sourcepub fn build(root: &Expression) -> Self
pub fn build(root: &Expression) -> Self
Build context from an expression tree
Sourcepub fn get(&self, id: NodeId) -> Option<&ParentInfo>
pub fn get(&self, id: NodeId) -> Option<&ParentInfo>
Get parent info for a node
Trait Implementations§
Source§impl Debug for TreeContext
impl Debug for TreeContext
Source§impl Default for TreeContext
impl Default for TreeContext
Source§fn default() -> TreeContext
fn default() -> TreeContext
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for TreeContext
impl RefUnwindSafe for TreeContext
impl Send for TreeContext
impl Sync for TreeContext
impl Unpin for TreeContext
impl UnwindSafe for TreeContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more