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
use std::ops::Range;
use super::*;
#[derive(Debug, PartialEq, Clone)]
pub struct SchemaBlock<'a> {
pub span_range: SpanRange,
pub input: &'a str,
pub project: Option<project::ProjectBlock>,
pub tables: Vec<table::TableBlock>,
pub table_groups: Vec<table_group::TableGroupBlock>,
pub refs: Vec<refs::RefBlock>,
pub enums: Vec<enums::EnumBlock>,
}
impl<'a> SchemaBlock<'a> {
pub fn new(input: &'a str, span_range: Range<usize>) -> Self {
Self {
span_range,
input,
project: Option::default(),
tables: Vec::default(),
table_groups: Vec::default(),
refs: Vec::default(),
enums: Vec::default(),
}
}
pub fn print(&self) {
println!("Project:");
println!("{:?}\n----", self.project);
println!("Tables:");
self
.tables
.iter()
.for_each(|table| println!("{:?}\n----", table));
println!("TableGroups:");
self
.table_groups
.iter()
.for_each(|table| println!("{:?}\n----", table));
println!("Refs:");
self
.refs
.iter()
.for_each(|table| println!("{:?}\n----", table));
println!("Enums:");
self
.enums
.iter()
.for_each(|table| println!("{:?}\n----", table));
}
}