mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 12:33:33 +00:00
create leaf directly without calling the parser
This commit is contained in:
parent
4356240fa4
commit
c300135322
1 changed files with 2 additions and 23 deletions
|
@ -104,29 +104,8 @@ impl File {
|
|||
return None;
|
||||
}
|
||||
|
||||
let reparser: fn(&mut Parser) = if node.kind().is_trivia() {
|
||||
// since trivia is omitted by parser when it doesn't have a parent, \
|
||||
// we need to create one for it
|
||||
|p| {
|
||||
p.start().complete(p, ROOT);
|
||||
}
|
||||
} else {
|
||||
|p| {
|
||||
p.bump();
|
||||
}
|
||||
};
|
||||
|
||||
let (green, new_errors) =
|
||||
parser_impl::parse_with::<yellow::GreenBuilder>(
|
||||
&text, &tokens, reparser,
|
||||
);
|
||||
|
||||
let green = if node.kind().is_trivia() {
|
||||
green.children().first().cloned().unwrap()
|
||||
} else {
|
||||
green
|
||||
};
|
||||
|
||||
let green = GreenNode::new_leaf(node.kind(), &text);
|
||||
let new_errors = vec![];
|
||||
Some((node, green, new_errors))
|
||||
},
|
||||
_ => None,
|
||||
|
|
Loading…
Reference in a new issue