aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/parsing/text_token_source.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/parsing/text_token_source.rs')
-rw-r--r--crates/ra_syntax/src/parsing/text_token_source.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/crates/ra_syntax/src/parsing/text_token_source.rs b/crates/ra_syntax/src/parsing/text_token_source.rs
index 97aa3e795..df866dc2b 100644
--- a/crates/ra_syntax/src/parsing/text_token_source.rs
+++ b/crates/ra_syntax/src/parsing/text_token_source.rs
@@ -1,10 +1,10 @@
1//! See `TextTokenSource` docs. 1//! See `TextTokenSource` docs.
2 2
3use ra_parser::TokenSource; 3use parser::TokenSource;
4 4
5use crate::{parsing::lexer::Token, SyntaxKind::EOF, TextRange, TextSize}; 5use crate::{parsing::lexer::Token, SyntaxKind::EOF, TextRange, TextSize};
6 6
7/// Implementation of `ra_parser::TokenSource` that takes tokens from source code text. 7/// Implementation of `parser::TokenSource` that takes tokens from source code text.
8pub(crate) struct TextTokenSource<'t> { 8pub(crate) struct TextTokenSource<'t> {
9 text: &'t str, 9 text: &'t str,
10 /// token and its start position (non-whitespace/comment tokens) 10 /// token and its start position (non-whitespace/comment tokens)
@@ -20,15 +20,15 @@ pub(crate) struct TextTokenSource<'t> {
20 token_offset_pairs: Vec<(Token, TextSize)>, 20 token_offset_pairs: Vec<(Token, TextSize)>,
21 21
22 /// Current token and position 22 /// Current token and position
23 curr: (ra_parser::Token, usize), 23 curr: (parser::Token, usize),
24} 24}
25 25
26impl<'t> TokenSource for TextTokenSource<'t> { 26impl<'t> TokenSource for TextTokenSource<'t> {
27 fn current(&self) -> ra_parser::Token { 27 fn current(&self) -> parser::Token {
28 self.curr.0 28 self.curr.0
29 } 29 }
30 30
31 fn lookahead_nth(&self, n: usize) -> ra_parser::Token { 31 fn lookahead_nth(&self, n: usize) -> parser::Token {
32 mk_token(self.curr.1 + n, &self.token_offset_pairs) 32 mk_token(self.curr.1 + n, &self.token_offset_pairs)
33 } 33 }
34 34
@@ -49,7 +49,7 @@ impl<'t> TokenSource for TextTokenSource<'t> {
49 } 49 }
50} 50}
51 51
52fn mk_token(pos: usize, token_offset_pairs: &[(Token, TextSize)]) -> ra_parser::Token { 52fn mk_token(pos: usize, token_offset_pairs: &[(Token, TextSize)]) -> parser::Token {
53 let (kind, is_jointed_to_next) = match token_offset_pairs.get(pos) { 53 let (kind, is_jointed_to_next) = match token_offset_pairs.get(pos) {
54 Some((token, offset)) => ( 54 Some((token, offset)) => (
55 token.kind, 55 token.kind,
@@ -60,7 +60,7 @@ fn mk_token(pos: usize, token_offset_pairs: &[(Token, TextSize)]) -> ra_parser::
60 ), 60 ),
61 None => (EOF, false), 61 None => (EOF, false),
62 }; 62 };
63 ra_parser::Token { kind, is_jointed_to_next } 63 parser::Token { kind, is_jointed_to_next }
64} 64}
65 65
66impl<'t> TextTokenSource<'t> { 66impl<'t> TextTokenSource<'t> {