extractFunction/extractMethod, decision resolved once: method iff a receiver is found (fn inside an impl — including a NESTED fn inside an impl method's body, whose parent walk passes through the outer fn) or the stack top is class-like (trait members).
(&mut self, node: Node<'t>)
| 495 | /// impl method's body, whose parent walk passes through the outer fn) or |
| 496 | /// the stack top is class-like (trait members). |
| 497 | fn extract_fn_or_method(&mut self, node: Node<'t>) { |
| 498 | let receiver = self.receiver_type_of(node); |
| 499 | let as_method = receiver.is_some() || self.inside_class_like(); |
| 500 | |
| 501 | let name = self.extract_name(node); |
| 502 | if name == "<anonymous>" { |
| 503 | if let Some(body) = node.child_by_field_name("body") { |
| 504 | self.visit_function_body(body); |
| 505 | } |
| 506 | return; |
| 507 | } |
| 508 | |
| 509 | let extra = Extra { |
| 510 | docstring: preceding_docstring(node, self.src), |
| 511 | signature: self.signature_of(node), |
| 512 | visibility: Some(self.visibility_of(node)), |
| 513 | // isAsync hook exists but never finds a direct `async` child (it |
| 514 | // nests in function_modifiers) — present-false on every node. |
| 515 | is_async: Some(false), |
| 516 | return_type: self.return_type_of(node), |
| 517 | qualified_name: receiver.as_ref().map(|r| format!("{r}::{name}")), |
| 518 | ..Extra::default() // isExported hook absent → flag not set |
| 519 | }; |
| 520 | let kind: &'static str = if as_method { "method" } else { "function" }; |
| 521 | let Some(row) = self.create_node(kind, &name, node, extra) else { return }; |
| 522 | |
| 523 | // Contains edge from the owner: receiver present AND not class-like — |
| 524 | // FIRST earlier-in-file struct/class/enum/trait of the receiver's name. |
| 525 | if as_method && !self.inside_class_like() { |
| 526 | if let Some(receiver) = &receiver { |
| 527 | let owner_row = self |
| 528 | .nodes_meta |
| 529 | .iter() |
| 530 | .position(|m| { |
| 531 | m.name == *receiver |
| 532 | && matches!(m.kind, "struct" | "class" | "enum" | "trait") |
| 533 | }) |
| 534 | .map(|i| i as u32); |
| 535 | if let Some(owner_row) = owner_row { |
| 536 | self.tables.push_edge(&EdgeRow { |
| 537 | source_idx: owner_row, |
| 538 | target_idx: row, |
| 539 | kind: edge_kind_index("contains").unwrap(), |
| 540 | provenance: 0, |
| 541 | line: NONE, |
| 542 | column: NONE, |
| 543 | metadata_json: NONE_STR, |
| 544 | source_id_str: NONE_STR, |
| 545 | target_id_str: NONE_STR, |
| 546 | }); |
| 547 | } |
| 548 | } |
| 549 | } |
| 550 | |
| 551 | self.extract_type_annotations(node, row); |
| 552 | // extractDecoratorsFor: rust attribute_items are siblings, not |
| 553 | // decorator/annotation/attribute node types — complete no-op. |
| 554 | self.stack.push(Scope { row, kind, name }); |
no test coverage detected