Add classify_literal and undo expose next_token
This commit is contained in:
@@ -40,7 +40,7 @@ pub use crate::{
|
||||
syntax_text::SyntaxText,
|
||||
syntax_node::{Direction, SyntaxNode, WalkEvent, TreeArc, SyntaxTreeBuilder, SyntaxElement, SyntaxToken},
|
||||
ptr::{SyntaxNodePtr, AstPtr},
|
||||
parsing::{tokenize, next_token, Token},
|
||||
parsing::{tokenize, classify_literal, Token},
|
||||
};
|
||||
|
||||
use ra_text_edit::AtomTextEdit;
|
||||
|
||||
@@ -11,7 +11,7 @@ use crate::{
|
||||
syntax_node::GreenNode,
|
||||
};
|
||||
|
||||
pub use self::lexer::{tokenize, next_token, Token};
|
||||
pub use self::lexer::{tokenize, classify_literal, Token};
|
||||
|
||||
pub(crate) use self::reparsing::incremental_reparse;
|
||||
|
||||
|
||||
@@ -214,3 +214,12 @@ fn scan_literal_suffix(ptr: &mut Ptr) {
|
||||
}
|
||||
ptr.bump_while(is_ident_continue);
|
||||
}
|
||||
|
||||
pub fn classify_literal(text: &str) -> Option<Token> {
|
||||
let tkn = next_token(text);
|
||||
if tkn.kind.is_literal() || tkn.len.to_usize() != text.len() {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(tkn)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user