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>)
| 1041 | /// extractCall — swift rides the generic member branch (navigation) and |
| 1042 | /// the raw-text else; the full matrix is in the checklist. |
| 1043 | fn extract_call(&mut self, node: Node<'t>) { |
| 1044 | if self.stack.is_empty() { |
| 1045 | return; |
| 1046 | } |
| 1047 | let caller = self.top_row(); |
| 1048 | let func = node |
| 1049 | .child_by_field_name("function") |
| 1050 | .or_else(|| node.named_child(0)); |
| 1051 | let Some(func) = func else { return }; |
| 1052 | // `-(a + b)`: an operator token applied to a parenthesized value leaves |
| 1053 | // the call with no callee node, only its arguments (tree-sitter.ts). |
| 1054 | // `!(x)` keeps its `bang` callee: a project may declare `prefix func !`. |
| 1055 | if func.kind() == "call_suffix" { |
| 1056 | return; |
| 1057 | } |
| 1058 | let func = peel_call_wrappers(func, self.src); |
| 1059 | let mut callee_name = String::new(); |
| 1060 | |
| 1061 | if func.kind() == "navigation_expression" { |
| 1062 | // property = property/field fields (null) → namedChild(1), with |
| 1063 | // the navigation_suffix simple_identifier unwrap. |
| 1064 | let property = func |
| 1065 | .child_by_field_name("property") |
| 1066 | .or_else(|| func.child_by_field_name("field")) |
| 1067 | .or_else(|| { |
| 1068 | let c1 = func.named_child(1); |
| 1069 | match c1 { |
| 1070 | Some(c) if c.kind() == "navigation_suffix" => (0..c.named_child_count()) |
| 1071 | .filter_map(|i| c.named_child(i)) |
| 1072 | .find(|g| g.kind() == "simple_identifier") |
| 1073 | .or(Some(c)), |
| 1074 | other => other, |
| 1075 | } |
| 1076 | }); |
| 1077 | if let Some(property) = property { |
| 1078 | let method_name = self.text(property); |
| 1079 | // Through a prefix operator, `try` and `await`: |
| 1080 | // `(!store).contains(x)`, `(try! A()).b()`. |
| 1081 | let receiver = func |
| 1082 | .child_by_field_name("object") |
| 1083 | .or_else(|| func.child_by_field_name("operand")) |
| 1084 | .or_else(|| func.child_by_field_name("argument")) |
| 1085 | .or_else(|| func.named_child(0)) |
| 1086 | .map(|r| peel_call_wrappers(r, self.src)); |
| 1087 | if let Some(r) = receiver { |
| 1088 | if is_literal_receiver(r.kind()) { |
| 1089 | return; // `"lit".upper()` / `5.times()` — nothing |
| 1090 | } |
| 1091 | } |
| 1092 | let recv_ident = receiver.filter(|r| { |
| 1093 | matches!(r.kind(), "identifier" | "simple_identifier" | "field_identifier") |
| 1094 | }); |
| 1095 | if let Some(r) = recv_ident { |
| 1096 | let receiver_name = self.text(r); |
| 1097 | if matches!(receiver_name, "self" | "this" | "cls" | "super") { |
| 1098 | callee_name = method_name.to_string(); |
| 1099 | } else { |
| 1100 | callee_name = format!("{receiver_name}.{method_name}"); |
no test coverage detected