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
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.
pub fn fingerprint(&self) -> u64
Sourcepub fn calculate_hash(&self) -> u64
pub fn calculate_hash(&self) -> u64
Calculate a hash for this ASTNode
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, )
Recursively 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).