(&mut self, node: Node<'t>)
| 515 | } |
| 516 | |
| 517 | fn extract_method(&mut self, node: Node<'t>) { |
| 518 | // methodsAreTopLevel: always a method. Receiver-qualified name + |
| 519 | // a contains edge from the FIRST earlier struct/class/enum/trait |
| 520 | // node of the receiver's name (mirrors the this.nodes.find scan). |
| 521 | let receiver_type = self.receiver_type_of(node); |
| 522 | let name = self.extract_name(node); |
| 523 | let extra = Extra { |
| 524 | docstring: self.docstring_of(node), |
| 525 | signature: self.signature_of(node), |
| 526 | return_type: self.return_type_of(node), |
| 527 | qualified_name: receiver_type.as_ref().map(|r| format!("{r}::{name}")), |
| 528 | // methodsAreTopLevel: a Go method is a top-level declaration, so |
| 529 | // extractMethod gives it the function's exportedness (name case). |
| 530 | is_exported: Some(self.is_exported(node)), |
| 531 | ..Extra::default() |
| 532 | }; |
| 533 | let Some(row) = self.create_node("method", &name, node, extra) else { return }; |
| 534 | |
| 535 | if let Some(receiver_type) = &receiver_type { |
| 536 | if !self.inside_class_like() { |
| 537 | let owner_row = self |
| 538 | .nodes_meta |
| 539 | .iter() |
| 540 | .position(|m| { |
| 541 | m.name == *receiver_type |
| 542 | && matches!(m.kind, "struct" | "class" | "enum" | "trait") |
| 543 | }) |
| 544 | .map(|i| i as u32); |
| 545 | if let Some(owner_row) = owner_row { |
| 546 | self.tables.push_edge(&EdgeRow { |
| 547 | source_idx: owner_row, |
| 548 | target_idx: row, |
| 549 | kind: edge_kind_index("contains").unwrap(), |
| 550 | provenance: 0, |
| 551 | line: NONE, |
| 552 | column: NONE, |
| 553 | metadata_json: NONE_STR, |
| 554 | source_id_str: NONE_STR, |
| 555 | target_id_str: NONE_STR, |
| 556 | }); |
| 557 | } |
| 558 | } |
| 559 | } |
| 560 | |
| 561 | self.extract_type_annotations(node, row); |
| 562 | self.stack.push(Scope { row, kind: "method", name }); |
| 563 | if let Some(body) = node.child_by_field_name("body") { |
| 564 | self.visit_function_body(body); |
| 565 | } |
| 566 | self.stack.pop(); |
| 567 | } |
| 568 | |
| 569 | /// extractTypeAlias for Go: type_spec (`type A B`) and type_alias |
| 570 | /// (`type A = B`) → struct / interface / plain alias. |
no test coverage detected