aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/parser_impl.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/parser_impl.rs')
-rw-r--r--crates/ra_syntax/src/parser_impl.rs22
1 files changed, 5 insertions, 17 deletions
diff --git a/crates/ra_syntax/src/parser_impl.rs b/crates/ra_syntax/src/parser_impl.rs
index 01a51cd8d..f255dc23b 100644
--- a/crates/ra_syntax/src/parser_impl.rs
+++ b/crates/ra_syntax/src/parser_impl.rs
@@ -54,9 +54,7 @@ pub(crate) fn parse_with<S: Sink>(
54 parser(&mut parser_api); 54 parser(&mut parser_api);
55 parser_api.0.into_events() 55 parser_api.0.into_events()
56 }; 56 };
57 EventProcessor::new(sink, text, tokens, &mut events) 57 EventProcessor::new(sink, text, tokens, &mut events).process().finish()
58 .process()
59 .finish()
60} 58}
61 59
62/// Implementation details of `Parser`, extracted 60/// Implementation details of `Parser`, extracted
@@ -160,17 +158,13 @@ impl<'t> ParserImpl<'t> {
160 158
161 /// Append one Error event to the back of events. 159 /// Append one Error event to the back of events.
162 pub(super) fn error(&mut self, msg: String) { 160 pub(super) fn error(&mut self, msg: String) {
163 self.push_event(Event::Error { 161 self.push_event(Event::Error { msg: ParseError(msg) })
164 msg: ParseError(msg),
165 })
166 } 162 }
167 163
168 /// Complete an event with appending a `Finish` event. 164 /// Complete an event with appending a `Finish` event.
169 pub(super) fn complete(&mut self, pos: u32, kind: SyntaxKind) { 165 pub(super) fn complete(&mut self, pos: u32, kind: SyntaxKind) {
170 match self.events[pos as usize] { 166 match self.events[pos as usize] {
171 Event::Start { 167 Event::Start { kind: ref mut slot, .. } => {
172 kind: ref mut slot, ..
173 } => {
174 *slot = kind; 168 *slot = kind;
175 } 169 }
176 _ => unreachable!(), 170 _ => unreachable!(),
@@ -183,10 +177,7 @@ impl<'t> ParserImpl<'t> {
183 let idx = pos as usize; 177 let idx = pos as usize;
184 if idx == self.events.len() - 1 { 178 if idx == self.events.len() - 1 {
185 match self.events.pop() { 179 match self.events.pop() {
186 Some(Event::Start { 180 Some(Event::Start { kind: TOMBSTONE, forward_parent: None }) => (),
187 kind: TOMBSTONE,
188 forward_parent: None,
189 }) => (),
190 _ => unreachable!(), 181 _ => unreachable!(),
191 } 182 }
192 } 183 }
@@ -196,10 +187,7 @@ impl<'t> ParserImpl<'t> {
196 pub(super) fn precede(&mut self, pos: u32) -> u32 { 187 pub(super) fn precede(&mut self, pos: u32) -> u32 {
197 let new_pos = self.start(); 188 let new_pos = self.start();
198 match self.events[pos as usize] { 189 match self.events[pos as usize] {
199 Event::Start { 190 Event::Start { ref mut forward_parent, .. } => {
200 ref mut forward_parent,
201 ..
202 } => {
203 *forward_parent = Some(new_pos - pos); 191 *forward_parent = Some(new_pos - pos);
204 } 192 }
205 _ => unreachable!(), 193 _ => unreachable!(),