MCPcopy Create free account
hub / github.com/dprint/jsonc-parser / build

Method build

src/cst/mod.rs:2353–2372  ·  view source on GitHub ↗
(&mut self, ast_value: Option<crate::ast::Value<'a>>)

Source from the content-addressed store, hash-verified

2351
2352impl<'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 {

Callers 1

parseMethod · 0.80

Calls 5

CstRootNodeClass · 0.85
scan_from_toMethod · 0.80
build_valueMethod · 0.80
lenMethod · 0.80
rangeMethod · 0.45

Tested by

no test coverage detected