(&mut self, node: Node<'t>)
| 474 | } |
| 475 | |
| 476 | fn extract_method(&mut self, node: Node<'t>) { |
| 477 | // methodsAreTopLevel: always a method. Receiver-qualified name + |
| 478 | // a contains edge from the FIRST earlier struct/class/enum/trait |
| 479 | // node of the receiver's name (mirrors the this.nodes.find scan). |
| 480 | let receiver_type = self.receiver_type_of(node); |
| 481 | let name = self.extract_name(node); |
| 482 | let extra = Extra { |
| 483 | docstring: preceding_docstring(node, self.src), |
| 484 | signature: self.signature_of(node), |
| 485 | return_type: self.return_type_of(node), |
| 486 | qualified_name: receiver_type.as_ref().map(|r| format!("{r}::{name}")), |
| 487 | ..Extra::default() // extractMethod passes no isExported |
| 488 | }; |
| 489 | let Some(row) = self.create_node("method", &name, node, extra) else { return }; |
| 490 | |
| 491 | if let Some(receiver_type) = &receiver_type { |
| 492 | if !self.inside_class_like() { |
| 493 | let owner_row = self |
| 494 | .nodes_meta |
| 495 | .iter() |
| 496 | .position(|m| { |
| 497 | m.name == *receiver_type |
| 498 | && matches!(m.kind, "struct" | "class" | "enum" | "trait") |
| 499 | }) |
| 500 | .map(|i| i as u32); |
| 501 | if let Some(owner_row) = owner_row { |
| 502 | self.tables.push_edge(&EdgeRow { |
| 503 | source_idx: owner_row, |
| 504 | target_idx: row, |
| 505 | kind: edge_kind_index("contains").unwrap(), |
| 506 | provenance: 0, |
| 507 | line: NONE, |
| 508 | column: NONE, |
| 509 | metadata_json: NONE_STR, |
| 510 | source_id_str: NONE_STR, |
| 511 | target_id_str: NONE_STR, |
| 512 | }); |
| 513 | } |
| 514 | } |
| 515 | } |
| 516 | |
| 517 | self.extract_type_annotations(node, row); |
| 518 | self.stack.push(Scope { row, kind: "method", name }); |
| 519 | if let Some(body) = node.child_by_field_name("body") { |
| 520 | self.visit_function_body(body); |
| 521 | } |
| 522 | self.stack.pop(); |
| 523 | } |
| 524 | |
| 525 | /// extractTypeAlias for Go: type_spec → struct / interface / plain alias. |
| 526 | fn extract_type_alias(&mut self, node: Node<'t>) -> bool { |
no test coverage detected