diff options
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r-- | crates/ra_syntax/src/lib.rs | 2 | ||||
-rw-r--r-- | crates/ra_syntax/src/parsing.rs | 2 | ||||
-rw-r--r-- | crates/ra_syntax/src/parsing/lexer.rs | 9 |
3 files changed, 11 insertions, 2 deletions
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs index 1cbc3e9e1..c56bc9f16 100644 --- a/crates/ra_syntax/src/lib.rs +++ b/crates/ra_syntax/src/lib.rs | |||
@@ -40,7 +40,7 @@ pub use crate::{ | |||
40 | syntax_text::SyntaxText, | 40 | syntax_text::SyntaxText, |
41 | syntax_node::{Direction, SyntaxNode, WalkEvent, TreeArc, SyntaxTreeBuilder, SyntaxElement, SyntaxToken}, | 41 | syntax_node::{Direction, SyntaxNode, WalkEvent, TreeArc, SyntaxTreeBuilder, SyntaxElement, SyntaxToken}, |
42 | ptr::{SyntaxNodePtr, AstPtr}, | 42 | ptr::{SyntaxNodePtr, AstPtr}, |
43 | parsing::{tokenize, next_token, Token}, | 43 | parsing::{tokenize, classify_literal, Token}, |
44 | }; | 44 | }; |
45 | 45 | ||
46 | use ra_text_edit::AtomTextEdit; | 46 | use ra_text_edit::AtomTextEdit; |
diff --git a/crates/ra_syntax/src/parsing.rs b/crates/ra_syntax/src/parsing.rs index f0750d737..15d69c5ab 100644 --- a/crates/ra_syntax/src/parsing.rs +++ b/crates/ra_syntax/src/parsing.rs | |||
@@ -11,7 +11,7 @@ use crate::{ | |||
11 | syntax_node::GreenNode, | 11 | syntax_node::GreenNode, |
12 | }; | 12 | }; |
13 | 13 | ||
14 | pub use self::lexer::{tokenize, next_token, Token}; | 14 | pub use self::lexer::{tokenize, classify_literal, Token}; |
15 | 15 | ||
16 | pub(crate) use self::reparsing::incremental_reparse; | 16 | pub(crate) use self::reparsing::incremental_reparse; |
17 | 17 | ||
diff --git a/crates/ra_syntax/src/parsing/lexer.rs b/crates/ra_syntax/src/parsing/lexer.rs index 36e841609..e75f3aae0 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 | } | ||