rbx_rsml/parser/tree_node_group/
tree_node.rs

1use std::collections::HashMap;
2use rbx_types::Attributes;
3
4use crate::Datatype;
5
6#[derive(Debug)]
7pub struct TreeNode {
8    pub selector: Option<String>,
9    pub name: Option<String>,
10    pub priority: Option<i32>,
11    pub attributes: Attributes,
12    pub static_attributes: HashMap<String, Datatype>,
13    pub properties: Attributes,
14    pub child_rules: Vec<usize>,
15    pub parent: TreeNodeType
16}
17
18#[derive(Clone, PartialEq, Copy, Eq, Debug, Hash)]
19pub enum TreeNodeType {
20    Root,
21    Node(usize)
22}
23
24impl TreeNode {
25    pub fn new(parent: TreeNodeType, selector: Option<String>) -> Self {
26        Self {
27            attributes: Attributes::new(),
28            static_attributes: HashMap::new(),
29            properties: Attributes::new(),
30            child_rules: vec![],
31            priority: None,
32            name: None,
33            selector,
34            parent
35        }
36    }
37}