pub struct ASTNode {
pub node_type: ASTNodeType,
pub source_token: Option<Token>,
pub contains_volatile: bool,
}Expand description
An AST node represents a parsed formula element
§Depth
Hashing (Self::fingerprint, Self::calculate_hash, Hash),
pretty-printing, Display and the derived Clone, PartialEq, Debug,
serde and drop glue recurse once per tree level. Trees within the default
ParserLimits::ast_height limit (256)
are supported, which includes every tree the parser returns under default
limits. A taller tree, hand-built or parsed under a raised limit, needs the
caller to provide the stack (see
ParserLimits::with_ast_height).
Reference walks (Self::visit_refs, Self::refs,
Self::get_dependencies, Self::collect_references,
Self::update_sheet_references) use an explicit stack and have no
depth limit.
Fields§
§node_type: ASTNodeType§source_token: Option<Token>§contains_volatile: boolTrue if this AST contains any volatile function calls.
This is set by the parser when a volatility classifier is provided. For ASTs constructed manually (e.g., in tests), this defaults to false.
Implementations§
Source§impl ASTNode
impl ASTNode
pub fn new(node_type: ASTNodeType, source_token: Option<Token>) -> Self
Sourcepub fn new_with_volatile(
node_type: ASTNodeType,
source_token: Option<Token>,
contains_volatile: bool,
) -> Self
pub fn new_with_volatile( node_type: ASTNodeType, source_token: Option<Token>, contains_volatile: bool, ) -> Self
Create an ASTNode while explicitly setting contains_volatile.
Sourcepub fn contains_volatile(&self) -> bool
pub fn contains_volatile(&self) -> bool
Whether this AST contains any volatile functions.
Sourcepub fn fingerprint(&self) -> u64
pub fn fingerprint(&self) -> u64
Structural fingerprint of this tree; the same value as
Self::calculate_hash.
§Depth
Recursive in the tree height. Trees within the default
ParserLimits::ast_height limit (256)
are supported, which includes every tree the parser returns under default
limits. A taller tree, hand-built or parsed under a raised limit, needs the
caller to provide the stack (see
ParserLimits::with_ast_height).
Sourcepub fn calculate_hash(&self) -> u64
pub fn calculate_hash(&self) -> u64
Calculate a hash for this ASTNode
§Depth
Recursive in the tree height. Trees within the default
ParserLimits::ast_height limit (256)
are supported, which includes every tree the parser returns under default
limits. A taller tree, hand-built or parsed under a raised limit, needs the
caller to provide the stack (see
ParserLimits::with_ast_height).
pub fn get_dependencies(&self) -> Vec<&ReferenceType>
pub fn get_dependency_strings(&self) -> Vec<String>
Sourcepub fn refs(&self) -> RefIter<'_> ⓘ
pub fn refs(&self) -> RefIter<'_> ⓘ
Lightweight borrowed view of a reference encountered during AST traversal. This mirrors ReferenceType variants but borrows sheet/name strings to avoid allocation.
Sourcepub fn visit_refs<V: FnMut(RefView<'_>)>(&self, visitor: V)
pub fn visit_refs<V: FnMut(RefView<'_>)>(&self, visitor: V)
Visit all references in this AST without allocating intermediates.
Sourcepub fn collect_references(
&self,
policy: &CollectPolicy,
) -> SmallVec<[ReferenceType; 4]>
pub fn collect_references( &self, policy: &CollectPolicy, ) -> SmallVec<[ReferenceType; 4]>
Convenience: collect references into a small, inline vector based on a policy.
Sourcepub fn update_sheet_references(
&mut self,
target_name: Option<&str>,
new_name: &str,
)
pub fn update_sheet_references( &mut self, target_name: Option<&str>, new_name: &str, )
Updates sheet references within the AST.
If target_name is provided, only references matching that sheet name are updated.
This is used for “healing” specific broken references (Tombstone rescue).
If target_name is None, it acts as a global rename (standard sheet rename).
The walk uses an explicit stack, so tree depth is not limited by the call stack.