diff options
Diffstat (limited to 'crates/ra_syntax/src/parsing/text_token_source.rs')
-rw-r--r-- | crates/ra_syntax/src/parsing/text_token_source.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/crates/ra_syntax/src/parsing/text_token_source.rs b/crates/ra_syntax/src/parsing/text_token_source.rs index e2433913c..7ddc2c2c3 100644 --- a/crates/ra_syntax/src/parsing/text_token_source.rs +++ b/crates/ra_syntax/src/parsing/text_token_source.rs | |||
@@ -3,7 +3,7 @@ | |||
3 | use ra_parser::Token as PToken; | 3 | use ra_parser::Token as PToken; |
4 | use ra_parser::TokenSource; | 4 | use ra_parser::TokenSource; |
5 | 5 | ||
6 | use crate::{parsing::lexer::Token, SyntaxKind::EOF, TextRange, TextUnit}; | 6 | use crate::{parsing::lexer::Token, SyntaxKind::EOF, TextRange, TextSize}; |
7 | 7 | ||
8 | pub(crate) struct TextTokenSource<'t> { | 8 | pub(crate) struct TextTokenSource<'t> { |
9 | text: &'t str, | 9 | text: &'t str, |
@@ -15,7 +15,7 @@ pub(crate) struct TextTokenSource<'t> { | |||
15 | /// 0 7 10 | 15 | /// 0 7 10 |
16 | /// ``` | 16 | /// ``` |
17 | /// (token, start_offset): `[(struct, 0), (Foo, 7), (;, 10)]` | 17 | /// (token, start_offset): `[(struct, 0), (Foo, 7), (;, 10)]` |
18 | start_offsets: Vec<TextUnit>, | 18 | start_offsets: Vec<TextSize>, |
19 | /// non-whitespace/comment tokens | 19 | /// non-whitespace/comment tokens |
20 | /// ```non-rust | 20 | /// ```non-rust |
21 | /// struct Foo {} | 21 | /// struct Foo {} |
@@ -51,12 +51,12 @@ impl<'t> TokenSource for TextTokenSource<'t> { | |||
51 | if pos >= self.tokens.len() { | 51 | if pos >= self.tokens.len() { |
52 | return false; | 52 | return false; |
53 | } | 53 | } |
54 | let range = TextRange::offset_len(self.start_offsets[pos], self.tokens[pos].len); | 54 | let range = TextRange::at(self.start_offsets[pos], self.tokens[pos].len); |
55 | self.text[range] == *kw | 55 | self.text[range] == *kw |
56 | } | 56 | } |
57 | } | 57 | } |
58 | 58 | ||
59 | fn mk_token(pos: usize, start_offsets: &[TextUnit], tokens: &[Token]) -> PToken { | 59 | fn mk_token(pos: usize, start_offsets: &[TextSize], tokens: &[Token]) -> PToken { |
60 | let kind = tokens.get(pos).map(|t| t.kind).unwrap_or(EOF); | 60 | let kind = tokens.get(pos).map(|t| t.kind).unwrap_or(EOF); |
61 | let is_jointed_to_next = if pos + 1 < start_offsets.len() { | 61 | let is_jointed_to_next = if pos + 1 < start_offsets.len() { |
62 | start_offsets[pos] + tokens[pos].len == start_offsets[pos + 1] | 62 | start_offsets[pos] + tokens[pos].len == start_offsets[pos + 1] |