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>)
| 504 | /// impl method's body, whose parent walk passes through the outer fn) or |
| 505 | /// the stack top is class-like (trait members). |
| 506 | fn extract_fn_or_method(&mut self, node: Node<'t>) { |
| 507 | stack_guard!(); |
| 508 | let receiver = self.receiver_type_of(node); |
| 509 | let as_method = receiver.is_some() || self.inside_class_like(); |
| 510 | |
| 511 | let name = self.extract_name(node); |
| 512 | if name == "<anonymous>" { |
| 513 | if let Some(body) = node.child_by_field_name("body") { |
| 514 | self.visit_function_body(body); |
| 515 | } |
| 516 | return; |
| 517 | } |
| 518 | |
| 519 | let extra = Extra { |
| 520 | docstring: preceding_docstring(node, self.src), |
| 521 | signature: self.signature_of(node), |
| 522 | visibility: Some(self.visibility_of(node)), |
| 523 | // isAsync hook exists but never finds a direct `async` child (it |
| 524 | // nests in function_modifiers) — present-false on every node. |
| 525 | is_async: Some(false), |
| 526 | return_type: self.return_type_of(node), |
| 527 | qualified_name: receiver.as_ref().map(|r| format!("{r}::{name}")), |
| 528 | ..Extra::default() // isExported hook absent → flag not set |
| 529 | }; |
| 530 | let kind: &'static str = if as_method { "method" } else { "function" }; |
| 531 | let Some(row) = self.create_node(kind, &name, node, extra) else { return }; |
| 532 | |
| 533 | // Contains edge from the owner: receiver present AND not class-like — |
| 534 | // FIRST earlier-in-file struct/class/enum/trait of the receiver's name. |
| 535 | if as_method && !self.inside_class_like() { |
| 536 | if let Some(receiver) = &receiver { |
| 537 | let owner_row = self |
| 538 | .nodes_meta |
| 539 | .iter() |
| 540 | .position(|m| { |
| 541 | m.name == *receiver |
| 542 | && matches!(m.kind, "struct" | "union" | "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 | // extractDecoratorsFor: rust attribute_items are siblings, not |
| 563 | // decorator/annotation/attribute node types — complete no-op. |
no test coverage detected