(&mut self, ast_value: Option<crate::ast::Value<'a>>)
| 2351 | |
| 2352 | impl<'a> CstBuilder<'a> { |
| 2353 | pub fn build(&mut self, ast_value: Option<crate::ast::Value<'a>>) -> CstRootNode { |
| 2354 | let root_node = CstContainerNode::Root(CstRootNode(Rc::new(RefCell::new(CstChildrenInner { |
| 2355 | parent: None, |
| 2356 | value: Vec::new(), |
| 2357 | })))); |
| 2358 | |
| 2359 | if let Some(ast_value) = ast_value { |
| 2360 | let range = ast_value.range(); |
| 2361 | self.scan_from_to(&root_node, 0, range.start); |
| 2362 | self.build_value(&root_node, ast_value); |
| 2363 | self.scan_from_to(&root_node, range.end, self.text.len()); |
| 2364 | } else { |
| 2365 | self.scan_from_to(&root_node, 0, self.text.len()); |
| 2366 | } |
| 2367 | |
| 2368 | match root_node { |
| 2369 | CstContainerNode::Root(node) => node, |
| 2370 | _ => unreachable!(), |
| 2371 | } |
| 2372 | } |
| 2373 | |
| 2374 | fn scan_from_to(&mut self, container: &CstContainerNode, from: usize, to: usize) { |
| 2375 | if from == to { |
no test coverage detected