diff options
author | darksv <[email protected]> | 2018-09-14 17:09:33 +0100 |
---|---|---|
committer | darksv <[email protected]> | 2018-09-14 18:23:10 +0100 |
commit | c300135322730cd685b03d1adc8b8c7c7e714b0a (patch) | |
tree | e1a9e5cd438c7210def502a18687919adb61c16b /crates | |
parent | 4356240fa42eebbd17fdb63b2d0e6f86387ca21c (diff) |
create leaf directly without calling the parser
Diffstat (limited to 'crates')
-rw-r--r-- | crates/libsyntax2/src/lib.rs | 25 |
1 files changed, 2 insertions, 23 deletions
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 { | |||
104 | return None; | 104 | return None; |
105 | } | 105 | } |
106 | 106 | ||
107 | let reparser: fn(&mut Parser) = if node.kind().is_trivia() { | 107 | let green = GreenNode::new_leaf(node.kind(), &text); |
108 | // since trivia is omitted by parser when it doesn't have a parent, \ | 108 | let new_errors = vec![]; |
109 | // we need to create one for it | ||
110 | |p| { | ||
111 | p.start().complete(p, ROOT); | ||
112 | } | ||
113 | } else { | ||
114 | |p| { | ||
115 | p.bump(); | ||
116 | } | ||
117 | }; | ||
118 | |||
119 | let (green, new_errors) = | ||
120 | parser_impl::parse_with::<yellow::GreenBuilder>( | ||
121 | &text, &tokens, reparser, | ||
122 | ); | ||
123 | |||
124 | let green = if node.kind().is_trivia() { | ||
125 | green.children().first().cloned().unwrap() | ||
126 | } else { | ||
127 | green | ||
128 | }; | ||
129 | |||
130 | Some((node, green, new_errors)) | 109 | Some((node, green, new_errors)) |
131 | }, | 110 | }, |
132 | _ => None, | 111 | _ => None, |