(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra)
| 480 | } |
| 481 | |
| 482 | fn create_node(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra) -> Option<u32> { |
| 483 | if name.is_empty() { |
| 484 | return None; |
| 485 | } |
| 486 | let start_line = self.line_of(node); |
| 487 | let id = ids::node_id(self.file_path, kind, name, start_line); |
| 488 | // (c/cpp define no resolveBody hook, so createNode's endLine extension |
| 489 | // for sibling-body grammars never fires — endLine is the node's own.) |
| 490 | let end_line = node.end_position().row as u32 + 1; |
| 491 | |
| 492 | let qualified = extra.qualified_name.unwrap_or_else(|| { |
| 493 | let mut parts: Vec<&str> = self.namespace_prefix.iter().map(|s| s.as_str()).collect(); |
| 494 | for s in &self.stack { |
| 495 | if s.kind != "file" { |
| 496 | parts.push(&s.name); |
| 497 | } |
| 498 | } |
| 499 | let mut qn = parts.join("::"); |
| 500 | if !qn.is_empty() { |
| 501 | qn.push_str("::"); |
| 502 | } |
| 503 | qn.push_str(name); |
| 504 | qn |
| 505 | }); |
| 506 | |
| 507 | let mut flags = BoolFlags::default(); |
| 508 | if let Some(v) = extra.is_exported { |
| 509 | flags.set(FLAG_IS_EXPORTED, v); |
| 510 | } |
| 511 | let name_ref = self.arena.put(name); |
| 512 | let qn_ref = self.arena.put(&qualified); |
| 513 | let id_ref = self.arena.put(&id); |
| 514 | let doc_ref = opt_str(&mut self.arena, extra.docstring.as_deref()); |
| 515 | let sig_ref = opt_str(&mut self.arena, extra.signature.as_deref()); |
| 516 | let ret_ref = opt_str(&mut self.arena, extra.return_type.as_deref()); |
| 517 | let row = self.tables.push_node(&NodeRow { |
| 518 | kind: node_kind_index(kind).unwrap(), |
| 519 | visibility: extra.visibility.unwrap_or(0), |
| 520 | flags, |
| 521 | start_line, |
| 522 | end_line, |
| 523 | start_column: self.col_of(node), |
| 524 | end_column: self.end_col_of(node), |
| 525 | name: name_ref, |
| 526 | qualified_name: qn_ref, |
| 527 | id: id_ref, |
| 528 | docstring: doc_ref, |
| 529 | signature: sig_ref, |
| 530 | decorators: NONE_STR, |
| 531 | type_parameters: NONE_STR, |
| 532 | return_type: ret_ref, |
| 533 | extra_json: NONE_STR, |
| 534 | }); |
| 535 | self.nodes_meta.push(NodeMeta { kind, name: name.to_string() }); |
| 536 | self.node_ids.push(id); |
| 537 | |
| 538 | let parent_row = self.top_row(); |
| 539 | self.tables.push_edge(&EdgeRow { |
no test coverage detected