From c300135322730cd685b03d1adc8b8c7c7e714b0a Mon Sep 17 00:00:00 2001 From: darksv Date: Fri, 14 Sep 2018 18:09:33 +0200 Subject: create leaf directly without calling the parser --- crates/libsyntax2/src/lib.rs | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) (limited to 'crates/libsyntax2') diff --git a/crates/libsyntax2/src/lib.rs b/crates/libsyntax2/src/lib.rs index bae685fb4..d124d3284 100644 --- a/crates/libsyntax2/src/lib.rs +++ b/crates/libsyntax2/src/lib.rs @@ -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::( - &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, -- cgit v1.2.3