extractCall — swift rides the generic member branch (navigation) and the raw-text else; the full matrix is in the checklist.
(&mut self, node: Node<'t>)
| 1066 | /// extractCall — swift rides the generic member branch (navigation) and |
| 1067 | /// the raw-text else; the full matrix is in the checklist. |
| 1068 | fn extract_call(&mut self, node: Node<'t>) { |
| 1069 | if self.stack.is_empty() { |
| 1070 | return; |
| 1071 | } |
| 1072 | let caller = self.top_row(); |
| 1073 | let func = node |
| 1074 | .child_by_field_name("function") |
| 1075 | .or_else(|| node.named_child(0)); |
| 1076 | let Some(func) = func else { return }; |
| 1077 | // `-(a + b)`: an operator token applied to a parenthesized value leaves |
| 1078 | // the call with no callee node, only its arguments (tree-sitter.ts). |
| 1079 | // `!(x)` keeps its `bang` callee: a project may declare `prefix func !`. |
| 1080 | if func.kind() == "call_suffix" { |
| 1081 | return; |
| 1082 | } |
| 1083 | let func = peel_call_wrappers(func, self.src); |
| 1084 | let mut callee_name = String::new(); |
| 1085 | |
| 1086 | if func.kind() == "navigation_expression" { |
| 1087 | // property = property/field fields (null) → namedChild(1), with |
| 1088 | // the navigation_suffix simple_identifier unwrap. |
| 1089 | let property = func |
| 1090 | .child_by_field_name("property") |
| 1091 | .or_else(|| func.child_by_field_name("field")) |
| 1092 | .or_else(|| { |
| 1093 | let c1 = func.named_child(1); |
| 1094 | match c1 { |
| 1095 | Some(c) if c.kind() == "navigation_suffix" => (0..c.named_child_count()) |
| 1096 | .filter_map(|i| c.named_child(i)) |
| 1097 | .find(|g| g.kind() == "simple_identifier") |
| 1098 | .or(Some(c)), |
| 1099 | other => other, |
| 1100 | } |
| 1101 | }); |
| 1102 | if let Some(property) = property { |
| 1103 | let method_name = self.text(property); |
| 1104 | // Through a prefix operator, `try` and `await`: |
| 1105 | // `(!store).contains(x)`, `(try! A()).b()`. |
| 1106 | let receiver = func |
| 1107 | .child_by_field_name("object") |
| 1108 | .or_else(|| func.child_by_field_name("operand")) |
| 1109 | .or_else(|| func.child_by_field_name("argument")) |
| 1110 | .or_else(|| func.named_child(0)) |
| 1111 | .map(|r| peel_call_wrappers(r, self.src)); |
| 1112 | if let Some(r) = receiver { |
| 1113 | if is_literal_receiver(r.kind()) { |
| 1114 | return; // `"lit".upper()` / `5.times()` — nothing |
| 1115 | } |
| 1116 | } |
| 1117 | let recv_ident = receiver.filter(|r| { |
| 1118 | matches!(r.kind(), "identifier" | "simple_identifier" | "field_identifier") |
| 1119 | }); |
| 1120 | if let Some(r) = recv_ident { |
| 1121 | let receiver_name = self.text(r); |
| 1122 | if matches!(receiver_name, "self" | "this" | "cls" | "super") { |
| 1123 | callee_name = method_name.to_string(); |
| 1124 | } else { |
| 1125 | callee_name = format!("{receiver_name}.{method_name}"); |
no test coverage detected