mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
create leaf directly without calling the parser
This commit is contained in:
parent
4356240fa4
commit
c300135322
@ -104,29 +104,8 @@ impl File {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let reparser: fn(&mut Parser) = if node.kind().is_trivia() {
|
let green = GreenNode::new_leaf(node.kind(), &text);
|
||||||
// since trivia is omitted by parser when it doesn't have a parent, \
|
let new_errors = vec![];
|
||||||
// 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
|
|
||||||
};
|
|
||||||
|
|
||||||
Some((node, green, new_errors))
|
Some((node, green, new_errors))
|
||||||
},
|
},
|
||||||
_ => None,
|
_ => None,
|
||||||
|
Loading…
Reference in New Issue
Block a user