Skip to main content

fluidattacks_blends_domain/ast/
node.rs

1//! AST node: source position, tree-sitter kind, optional text, named fields.
2
3use alloc::collections::BTreeMap;
4use alloc::string::String;
5
6use crate::NodeId;
7
8#[derive(Clone, PartialEq, Eq, Debug)]
9pub struct AstNode {
10    pub line: u32,
11    pub col: u32,
12    pub kind: String,
13    pub text: Option<String>,
14    pub fields: BTreeMap<String, NodeId>,
15}
16
17impl AstNode {
18    #[must_use]
19    pub const fn new(line: u32, col: u32, kind: String) -> Self {
20        Self {
21            line,
22            col,
23            kind,
24            text: None,
25            fields: BTreeMap::new(),
26        }
27    }
28}