mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
Simplify
This commit is contained in:
parent
d94124e3b4
commit
c74eaf1fdf
1 changed files with 5 additions and 7 deletions
|
@ -10,16 +10,14 @@ use self::event::Event;
|
|||
|
||||
/// Parse a sequence of tokens into the representative node tree
|
||||
pub fn parse(text: String, tokens: &[Token]) -> File {
|
||||
let events = parse_into_events(&text, tokens);
|
||||
let events = {
|
||||
let mut parser = parser::Parser::new(&text, tokens);
|
||||
grammar::file(&mut parser);
|
||||
parser.into_events()
|
||||
};
|
||||
event::to_file(text, tokens, events)
|
||||
}
|
||||
|
||||
pub(crate) fn parse_into_events<'t>(text: &'t str, raw_tokens: &'t [Token]) -> Vec<Event> {
|
||||
let mut parser = parser::Parser::new(text, raw_tokens);
|
||||
grammar::file(&mut parser);
|
||||
parser.into_events()
|
||||
}
|
||||
|
||||
fn is_insignificant(kind: SyntaxKind) -> bool {
|
||||
match kind {
|
||||
WHITESPACE | COMMENT => true,
|
||||
|
|
Loading…
Reference in a new issue