(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra)
| 542 | } |
| 543 | |
| 544 | fn create_node(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra) -> Option<u32> { |
| 545 | if name.is_empty() { |
| 546 | return None; |
| 547 | } |
| 548 | let start_line = self.line_of(node); |
| 549 | let column = self.col_of(node); |
| 550 | let id = self.node_id_allocator.generate(self.file_path, kind, name, start_line, column); |
| 551 | // (c/cpp define no resolveBody hook, so createNode's endLine extension |
| 552 | // for sibling-body grammars never fires — endLine is the node's own, |
| 553 | // or the `}` of its body in brace scopes.) |
| 554 | let (end_line, end_column) = |
| 555 | extra.end.unwrap_or_else(|| (node.end_position().row as u32 + 1, self.end_col_of(node))); |
| 556 | |
| 557 | let qualified = extra.qualified_name.unwrap_or_else(|| { |
| 558 | let mut parts: Vec<&str> = self.namespace_prefix.iter().map(|s| s.as_str()).collect(); |
| 559 | for s in &self.stack { |
| 560 | if let Some(q) = &s.qualified { |
| 561 | parts.clear(); |
| 562 | parts.push(q); |
| 563 | } else if s.kind != "file" { |
| 564 | parts.push(&s.name); |
| 565 | } |
| 566 | } |
| 567 | let mut qn = parts.join("::"); |
| 568 | if !qn.is_empty() { |
| 569 | qn.push_str("::"); |
| 570 | } |
| 571 | qn.push_str(name); |
| 572 | qn |
| 573 | }); |
| 574 | |
| 575 | let mut flags = BoolFlags::default(); |
| 576 | if let Some(v) = extra.is_exported { |
| 577 | flags.set(FLAG_IS_EXPORTED, v); |
| 578 | } |
| 579 | if let Some(v) = extra.is_abstract { |
| 580 | flags.set(FLAG_IS_ABSTRACT, v); |
| 581 | } |
| 582 | let name_ref = self.arena.put(name); |
| 583 | let qn_ref = self.arena.put(&qualified); |
| 584 | let id_ref = self.arena.put(&id); |
| 585 | let doc_ref = opt_str(&mut self.arena, extra.docstring.as_deref()); |
| 586 | let sig_ref = opt_str(&mut self.arena, extra.signature.as_deref()); |
| 587 | let ret_ref = opt_str(&mut self.arena, extra.return_type.as_deref()); |
| 588 | let row = self.tables.push_node(&NodeRow { |
| 589 | kind: node_kind_index(kind).unwrap(), |
| 590 | visibility: extra.visibility.unwrap_or(0), |
| 591 | flags, |
| 592 | start_line, |
| 593 | end_line, |
| 594 | start_column: self.col_of(node), |
| 595 | end_column, |
| 596 | name: name_ref, |
| 597 | qualified_name: qn_ref, |
| 598 | id: id_ref, |
| 599 | docstring: doc_ref, |
| 600 | signature: sig_ref, |
| 601 | decorators: NONE_STR, |
no test coverage detected