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