diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-04-05 15:17:07 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-04-05 15:17:07 +0100 |
commit | a52e86f9a9a21313a1543823b92e82c0a30e0870 (patch) | |
tree | 35d8b8b04a8e17a162fd6b95105db34919d59507 /crates/ra_syntax/src/parsing | |
parent | be9a44e9bad262ac5e615730e540fd434f846a0e (diff) | |
parent | 7abc06bd576264cb6b7c8becdbd1a8c0e914463d (diff) |
Merge #1112
1112: Fix literal support in token tree to ast item list r=matklad a=edwin0cheng
This PR implements following things :
1. Expose `next_token` from `ra_parse`
2. Fix the literal conversion in `token_tree_to_ast_item_list`
3. Add test for the conversion
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/parsing')
-rw-r--r-- | crates/ra_syntax/src/parsing/lexer.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/parsing/lexer.rs b/crates/ra_syntax/src/parsing/lexer.rs index 36e841609..3ae42912c 100644 --- a/crates/ra_syntax/src/parsing/lexer.rs +++ b/crates/ra_syntax/src/parsing/lexer.rs | |||
@@ -214,3 +214,12 @@ fn scan_literal_suffix(ptr: &mut Ptr) { | |||
214 | } | 214 | } |
215 | ptr.bump_while(is_ident_continue); | 215 | ptr.bump_while(is_ident_continue); |
216 | } | 216 | } |
217 | |||
218 | pub fn classify_literal(text: &str) -> Option<Token> { | ||
219 | let tkn = next_token(text); | ||
220 | if !tkn.kind.is_literal() || tkn.len.to_usize() != text.len() { | ||
221 | return None; | ||
222 | } | ||
223 | |||
224 | Some(tkn) | ||
225 | } | ||