aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/parsing/input.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/parsing/input.rs')
-rw-r--r--crates/ra_syntax/src/parsing/input.rs40
1 files changed, 20 insertions, 20 deletions
diff --git a/crates/ra_syntax/src/parsing/input.rs b/crates/ra_syntax/src/parsing/input.rs
index 58be795bc..31c6a3b9b 100644
--- a/crates/ra_syntax/src/parsing/input.rs
+++ b/crates/ra_syntax/src/parsing/input.rs
@@ -5,6 +5,26 @@ use crate::{
5 parsing::lexer::Token, 5 parsing::lexer::Token,
6}; 6};
7 7
8pub(crate) struct ParserInput<'t> {
9 text: &'t str,
10 /// start position of each token(expect whitespace and comment)
11 /// ```non-rust
12 /// struct Foo;
13 /// ^------^---
14 /// | | ^-
15 /// 0 7 10
16 /// ```
17 /// (token, start_offset): `[(struct, 0), (Foo, 7), (;, 10)]`
18 start_offsets: Vec<TextUnit>,
19 /// non-whitespace/comment tokens
20 /// ```non-rust
21 /// struct Foo {}
22 /// ^^^^^^ ^^^ ^^
23 /// ```
24 /// tokens: `[struct, Foo, {, }]`
25 tokens: Vec<Token>,
26}
27
8impl<'t> TokenSource for ParserInput<'t> { 28impl<'t> TokenSource for ParserInput<'t> {
9 fn token_kind(&self, pos: usize) -> SyntaxKind { 29 fn token_kind(&self, pos: usize) -> SyntaxKind {
10 if !(pos < self.tokens.len()) { 30 if !(pos < self.tokens.len()) {
@@ -28,26 +48,6 @@ impl<'t> TokenSource for ParserInput<'t> {
28 } 48 }
29} 49}
30 50
31pub(crate) struct ParserInput<'t> {
32 text: &'t str,
33 /// start position of each token(expect whitespace and comment)
34 /// ```non-rust
35 /// struct Foo;
36 /// ^------^---
37 /// | | ^-
38 /// 0 7 10
39 /// ```
40 /// (token, start_offset): `[(struct, 0), (Foo, 7), (;, 10)]`
41 start_offsets: Vec<TextUnit>,
42 /// non-whitespace/comment tokens
43 /// ```non-rust
44 /// struct Foo {}
45 /// ^^^^^^ ^^^ ^^
46 /// ```
47 /// tokens: `[struct, Foo, {, }]`
48 tokens: Vec<Token>,
49}
50
51impl<'t> ParserInput<'t> { 51impl<'t> ParserInput<'t> {
52 /// Generate input from tokens(expect comment and whitespace). 52 /// Generate input from tokens(expect comment and whitespace).
53 pub fn new(text: &'t str, raw_tokens: &'t [Token]) -> ParserInput<'t> { 53 pub fn new(text: &'t str, raw_tokens: &'t [Token]) -> ParserInput<'t> {