aboutsummaryrefslogtreecommitdiff
path: root/src/yellow
diff options
context:
space:
mode:
Diffstat (limited to 'src/yellow')
-rw-r--r--src/yellow/green.rs60
1 files changed, 30 insertions, 30 deletions
diff --git a/src/yellow/green.rs b/src/yellow/green.rs
index 8ddcc74b8..3ade46f45 100644
--- a/src/yellow/green.rs
+++ b/src/yellow/green.rs
@@ -79,6 +79,36 @@ fn assert_send_sync() {
79} 79}
80 80
81#[derive(Clone, Debug)] 81#[derive(Clone, Debug)]
82pub(crate) struct GreenBranch {
83 text_len: TextUnit,
84 kind: SyntaxKind,
85 children: Vec<GreenNode>,
86}
87
88impl GreenBranch {
89 fn new(kind: SyntaxKind, children: Vec<GreenNode>) -> GreenBranch {
90 let text_len = children.iter().map(|x| x.text_len()).sum::<TextUnit>();
91 GreenBranch {
92 text_len,
93 kind,
94 children,
95 }
96 }
97
98 pub fn kind(&self) -> SyntaxKind {
99 self.kind
100 }
101
102 pub fn text_len(&self) -> TextUnit {
103 self.text_len
104 }
105
106 pub fn children(&self) -> &[GreenNode] {
107 self.children.as_slice()
108 }
109}
110
111#[derive(Clone, Debug)]
82pub(crate) enum GreenLeaf { 112pub(crate) enum GreenLeaf {
83 Whitespace { 113 Whitespace {
84 newlines: u8, 114 newlines: u8,
@@ -143,33 +173,3 @@ const N_NEWLINES: usize = 16;
143const N_SPACES: usize = 64; 173const N_SPACES: usize = 64;
144const WS: &str = 174const WS: &str =
145 "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n "; 175 "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n ";
146
147#[derive(Clone, Debug)]
148pub(crate) struct GreenBranch {
149 text_len: TextUnit,
150 kind: SyntaxKind,
151 children: Vec<GreenNode>,
152}
153
154impl GreenBranch {
155 fn new(kind: SyntaxKind, children: Vec<GreenNode>) -> GreenBranch {
156 let text_len = children.iter().map(|x| x.text_len()).sum::<TextUnit>();
157 GreenBranch {
158 text_len,
159 kind,
160 children,
161 }
162 }
163
164 pub fn kind(&self) -> SyntaxKind {
165 self.kind
166 }
167
168 pub fn text_len(&self) -> TextUnit {
169 self.text_len
170 }
171
172 pub fn children(&self) -> &[GreenNode] {
173 self.children.as_slice()
174 }
175}