aboutsummaryrefslogtreecommitdiff
path: root/src/parser
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser')
-rw-r--r--src/parser/event.rs8
-rw-r--r--src/parser/input.rs4
2 files changed, 7 insertions, 5 deletions
diff --git a/src/parser/event.rs b/src/parser/event.rs
index 1c0905a38..ac8a55de9 100644
--- a/src/parser/event.rs
+++ b/src/parser/event.rs
@@ -1,5 +1,7 @@
1use {ErrorMsg, File, FileBuilder, Sink, SyntaxKind, TextUnit, Token}; 1use {
2use syntax_kinds::TOMBSTONE; 2 ErrorMsg, File, FileBuilder, Sink, SyntaxKind, Token,
3 syntax_kinds::TOMBSTONE,
4};
3use super::is_insignificant; 5use super::is_insignificant;
4 6
5/// `Parser` produces a flat list of `Event`s. 7/// `Parser` produces a flat list of `Event`s.
@@ -133,7 +135,7 @@ pub(super) fn to_file(text: String, tokens: &[Token], events: Vec<Event>) -> Fil
133 builder.leaf(token.kind, token.len); 135 builder.leaf(token.kind, token.len);
134 idx += 1 136 idx += 1
135 } 137 }
136 let mut len = TextUnit::new(0); 138 let mut len = 0.into();
137 for _ in 0..n_raw_tokens { 139 for _ in 0..n_raw_tokens {
138 len += tokens[idx].len; 140 len += tokens[idx].len;
139 idx += 1; 141 idx += 1;
diff --git a/src/parser/input.rs b/src/parser/input.rs
index 13589467b..9b400b959 100644
--- a/src/parser/input.rs
+++ b/src/parser/input.rs
@@ -14,7 +14,7 @@ impl<'t> ParserInput<'t> {
14 pub fn new(text: &'t str, raw_tokens: &'t [Token]) -> ParserInput<'t> { 14 pub fn new(text: &'t str, raw_tokens: &'t [Token]) -> ParserInput<'t> {
15 let mut tokens = Vec::new(); 15 let mut tokens = Vec::new();
16 let mut start_offsets = Vec::new(); 16 let mut start_offsets = Vec::new();
17 let mut len = TextUnit::new(0); 17 let mut len = 0.into();
18 for &token in raw_tokens.iter() { 18 for &token in raw_tokens.iter() {
19 if !is_insignificant(token.kind) { 19 if !is_insignificant(token.kind) {
20 tokens.push(token); 20 tokens.push(token);
@@ -44,7 +44,7 @@ impl<'t> ParserInput<'t> {
44 if !(idx < self.tokens.len()) { 44 if !(idx < self.tokens.len()) {
45 return ""; 45 return "";
46 } 46 }
47 let range = TextRange::from_len(self.start_offsets[idx], self.tokens[idx].len); 47 let range = TextRange::offset_len(self.start_offsets[idx], self.tokens[idx].len);
48 &self.text[range] 48 &self.text[range]
49 } 49 }
50} 50}