1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
use std::cell::RefCell;
use teo_teon::value::Value;

use crate::ast::identifier::Identifier;
use crate::ast::identifier_path::IdentifierPath;
use crate::ast::literals::DictionaryLiteral;
use crate::{declare_container_node, impl_container_node_defaults, node_child_fn, node_children_iter, node_children_iter_fn, node_optional_child_fn};
use crate::ast::doc_comment::DocComment;
use crate::format::Writer;
use crate::r#type::reference::Reference;
use crate::traits::has_availability::HasAvailability;
use crate::traits::info_provider::InfoProvider;
use crate::traits::resolved::Resolve;
use crate::traits::write::Write;

declare_container_node!(DataSet, named, availability,
    pub(crate) identifier: usize,
    pub auto_seed: bool,
    pub notrack: bool,
    pub(crate) groups: Vec<usize>,
    pub(crate) comment: Option<usize>,
);

impl_container_node_defaults!(DataSet, named, availability);

node_children_iter!(DataSet, DataSetGroup, GroupsIter, groups);

impl DataSet {

    node_optional_child_fn!(comment, DocComment);

    node_child_fn!(identifier, Identifier);

    node_children_iter_fn!(groups, GroupsIter);
}

impl InfoProvider for DataSet {
    fn namespace_skip(&self) -> usize {
        1
    }
}

declare_container_node!(DataSetGroup, named, availability,
    pub(crate) identifier_path: usize,
    pub(crate) records: Vec<usize>,
    pub(crate) resolved: RefCell<Option<Reference>>,
    pub(crate) comment: Option<usize>,
);

impl_container_node_defaults!(DataSetGroup, named, availability);

node_children_iter!(DataSetGroup, DataSetRecord, RecordsIter, records);

impl DataSetGroup {

    node_optional_child_fn!(comment, DocComment);

    node_child_fn!(identifier_path, IdentifierPath);

    node_children_iter_fn!(records, RecordsIter);
}

impl InfoProvider for DataSetGroup {
    fn namespace_skip(&self) -> usize {
        2
    }
}

impl Resolve<Reference> for DataSetGroup {
    fn resolved_ref_cell(&self) -> &RefCell<Option<Reference>> {
        &self.resolved
    }
}

declare_container_node!(DataSetRecord, named, availability,
    pub(crate) identifier: usize,
    pub(crate) dictionary: usize,
    pub(crate) resolved: RefCell<Option<Value>>,
    pub(crate) comment: Option<usize>,
);

impl_container_node_defaults!(DataSetRecord, named, availability);

impl DataSetRecord {

    node_optional_child_fn!(comment, DocComment);

    node_child_fn!(identifier, Identifier);

    node_child_fn!(dictionary, DictionaryLiteral);
}

impl InfoProvider for DataSetRecord {
    fn namespace_skip(&self) -> usize {
        3
    }
}

impl Resolve<Value> for DataSetRecord {
    fn resolved_ref_cell(&self) -> &RefCell<Option<Value>> {
        &self.resolved
    }
}

impl Write for DataSet {
    fn write<'a>(&'a self, writer: &mut Writer<'a>) {
        writer.write_children(self, self.children.values());
    }

    fn is_block_level_element(&self) -> bool {
        true
    }
}

impl Write for DataSetGroup {
    fn write<'a>(&'a self, writer: &mut Writer<'a>) {
        writer.write_children(self, self.children.values());
    }

    fn is_block_level_element(&self) -> bool {
        true
    }
}

impl Write for DataSetRecord {
    fn write<'a>(&'a self, writer: &mut Writer<'a>) {
        writer.write_children(self, self.children.values());
    }

    fn is_block_level_element(&self) -> bool {
        true
    }
}