extractCall — the bespoke ruby branch (tree-sitter.ts:3905-3960), reached only from the body walker.
(&mut self, node: Node<'t>)
| 794 | /// extractCall — the bespoke ruby branch (tree-sitter.ts:3905-3960), |
| 795 | /// reached only from the body walker. |
| 796 | fn extract_call(&mut self, node: Node<'t>) { |
| 797 | if self.stack.is_empty() { |
| 798 | return; |
| 799 | } |
| 800 | let caller = self.top_row(); |
| 801 | let method_name = match node.child_by_field_name("method") { |
| 802 | Some(m) => self.text(m), |
| 803 | None => "", |
| 804 | }; |
| 805 | if method_name.is_empty() { |
| 806 | return; // operator/element-reference call with no method name |
| 807 | } |
| 808 | let line = self.line_of(node); |
| 809 | let col = self.col_of(node); |
| 810 | let calls_kind = edge_kind_index("calls").unwrap(); |
| 811 | |
| 812 | let Some(receiver) = node.child_by_field_name("receiver") else { |
| 813 | // Bare `foo(...)` — just the method name. |
| 814 | self.push_ref(caller, &method_name.to_string(), calls_kind, line, col); |
| 815 | return; |
| 816 | }; |
| 817 | let receiver_name = self.text(receiver); |
| 818 | |
| 819 | // `Foo.new` / `NS::Widget.new` → instantiates ref to the LAST `::` |
| 820 | // segment; a non-capitalized receiver falls through to a calls ref |
| 821 | // (`lower.new`). |
| 822 | if method_name == "new" { |
| 823 | let class_name = match receiver_name.rfind("::") { |
| 824 | Some(i) => &receiver_name[i + 2..], |
| 825 | None => receiver_name, |
| 826 | }; |
| 827 | if class_name.as_bytes().first().map(|b| b.is_ascii_uppercase()).unwrap_or(false) { |
| 828 | self.push_ref( |
| 829 | caller, |
| 830 | &class_name.to_string(), |
| 831 | edge_kind_index("instantiates").unwrap(), |
| 832 | line, |
| 833 | col, |
| 834 | ); |
| 835 | return; |
| 836 | } |
| 837 | } |
| 838 | |
| 839 | // SKIP_RECEIVERS by TEXT — ruby's set is {self, super} only. `&.` |
| 840 | // joins with a plain `.`; chains/literals keep raw receiver text. |
| 841 | let skip = matches!(receiver_name, "self" | "super"); |
| 842 | let callee = if skip { |
| 843 | method_name.to_string() |
| 844 | } else if let Some(class_name) = self.constructed_class(receiver) { |
| 845 | // A call on what `Foo.new(…)` made: `new Foo().m`, not the |
| 846 | // receiver's text with its arguments in it (#684). |
| 847 | format!("new {class_name}().{method_name}") |
| 848 | } else { |
| 849 | format!("{receiver_name}.{method_name}") |
| 850 | }; |
| 851 | self.push_ref(caller, &callee, calls_kind, line, col); |
| 852 | |
| 853 | // Capitalized constant receiver (`Klass.static_call`, `RETRY_MAX.times`), |
no test coverage detected