aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/parsing/builder.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/parsing/builder.rs')
-rw-r--r--crates/ra_syntax/src/parsing/builder.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/crates/ra_syntax/src/parsing/builder.rs b/crates/ra_syntax/src/parsing/builder.rs
index 1041c6a7b..0775b0900 100644
--- a/crates/ra_syntax/src/parsing/builder.rs
+++ b/crates/ra_syntax/src/parsing/builder.rs
@@ -1,7 +1,9 @@
1use ra_parser::{TreeSink, ParseError};
2
1use crate::{ 3use crate::{
2 SmolStr, SyntaxError, SyntaxErrorKind, TextUnit, TextRange, 4 SmolStr, SyntaxError, SyntaxErrorKind, TextUnit, TextRange,
3 SyntaxKind::{self, *}, 5 SyntaxKind::{self, *},
4 parsing::{TreeSink, ParseError, Token}, 6 parsing::Token,
5 syntax_node::{GreenNode, RaTypes}, 7 syntax_node::{GreenNode, RaTypes},
6}; 8};
7 9
@@ -17,8 +19,6 @@ pub(crate) struct TreeBuilder<'a> {
17} 19}
18 20
19impl<'a> TreeSink for TreeBuilder<'a> { 21impl<'a> TreeSink for TreeBuilder<'a> {
20 type Tree = (GreenNode, Vec<SyntaxError>);
21
22 fn leaf(&mut self, kind: SyntaxKind, n_tokens: u8) { 22 fn leaf(&mut self, kind: SyntaxKind, n_tokens: u8) {
23 self.eat_trivias(); 23 self.eat_trivias();
24 let n_tokens = n_tokens as usize; 24 let n_tokens = n_tokens as usize;
@@ -65,10 +65,6 @@ impl<'a> TreeSink for TreeBuilder<'a> {
65 let error = SyntaxError::new(SyntaxErrorKind::ParseError(error), self.text_pos); 65 let error = SyntaxError::new(SyntaxErrorKind::ParseError(error), self.text_pos);
66 self.errors.push(error) 66 self.errors.push(error)
67 } 67 }
68
69 fn finish(self) -> (GreenNode, Vec<SyntaxError>) {
70 (self.inner.finish(), self.errors)
71 }
72} 68}
73 69
74impl<'a> TreeBuilder<'a> { 70impl<'a> TreeBuilder<'a> {
@@ -82,6 +78,11 @@ impl<'a> TreeBuilder<'a> {
82 inner: GreenNodeBuilder::new(), 78 inner: GreenNodeBuilder::new(),
83 } 79 }
84 } 80 }
81
82 pub(super) fn finish(self) -> (GreenNode, Vec<SyntaxError>) {
83 (self.inner.finish(), self.errors)
84 }
85
85 fn eat_trivias(&mut self) { 86 fn eat_trivias(&mut self) {
86 while let Some(&token) = self.tokens.get(self.token_pos) { 87 while let Some(&token) = self.tokens.get(self.token_pos) {
87 if !token.kind.is_trivia() { 88 if !token.kind.is_trivia() {