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>)
| 538 | /// impl method's body, whose parent walk passes through the outer fn) or |
| 539 | /// the stack top is class-like (trait members). |
| 540 | fn extract_fn_or_method(&mut self, node: Node<'t>) { |
| 541 | stack_guard!(); |
| 542 | let receiver = self.receiver_type_of(node); |
| 543 | let as_method = receiver.is_some() || self.inside_class_like(); |
| 544 | |
| 545 | let name = self.extract_name(node); |
| 546 | if name == "<anonymous>" { |
| 547 | if let Some(body) = node.child_by_field_name("body") { |
| 548 | self.visit_function_body(body); |
| 549 | } |
| 550 | return; |
| 551 | } |
| 552 | |
| 553 | // Match the wasm walker's sibling-attribute handling for Tauri commands. |
| 554 | let mut decorators = None; |
| 555 | if node.kind() == "function_item" { |
| 556 | let mut sibling = node.prev_named_sibling(); |
| 557 | while let Some(item) = sibling { |
| 558 | match item.kind() { |
| 559 | "line_comment" | "block_comment" => {}, |
| 560 | "attribute_item" => { |
| 561 | let name = item.named_child(0).and_then(|a| a.named_child(0)); |
| 562 | if let Some(name) = name { |
| 563 | let text: String = self.src[name.byte_range()].chars() |
| 564 | .filter(|c| !c.is_whitespace()).collect(); |
| 565 | if text == "tauri::command" { |
| 566 | decorators = Some("tauri::command".to_string()); |
| 567 | break; |
| 568 | } |
| 569 | } |
| 570 | }, |
| 571 | _ => break, |
| 572 | } |
| 573 | sibling = item.prev_named_sibling(); |
| 574 | } |
| 575 | } |
| 576 | let extra = Extra { |
| 577 | decorators, |
| 578 | docstring: preceding_docstring(node, self.src), |
| 579 | signature: self.signature_of(node), |
| 580 | visibility: Some(self.visibility_of(node)), |
| 581 | // isAsync hook exists but never finds a direct `async` child (it |
| 582 | // nests in function_modifiers) — present-false on every node. |
| 583 | is_async: Some(false), |
| 584 | return_type: self.return_type_of(node), |
| 585 | qualified_name: receiver.as_ref().map(|r| format!("{r}::{name}")), |
| 586 | ..Extra::default() // isExported hook absent → flag not set |
| 587 | }; |
| 588 | let kind: &'static str = if as_method { "method" } else { "function" }; |
| 589 | let Some(row) = self.create_node(kind, &name, node, extra) else { return }; |
| 590 | |
| 591 | // Contains edge from the owner: receiver present AND not class-like — |
| 592 | // FIRST earlier-in-file struct/class/enum/trait of the receiver's name. |
| 593 | if as_method && !self.inside_class_like() { |
| 594 | if let Some(receiver) = &receiver { |
| 595 | let owner_row = self |
| 596 | .nodes_meta |
| 597 | .iter() |
no test coverage detected