(&self, call: Node<'t>)
| 1231 | } |
| 1232 | |
| 1233 | fn find_rtk_endpoints_object(&self, call: Node<'t>) -> Option<Node<'t>> { |
| 1234 | let callee = call.child_by_field_name("function")?; |
| 1235 | let callee_name = match callee.kind() { |
| 1236 | "identifier" => self.text(callee), |
| 1237 | "member_expression" => { |
| 1238 | let prop = callee.child_by_field_name("property").unwrap_or(callee); |
| 1239 | self.text(prop) |
| 1240 | } |
| 1241 | _ => "", |
| 1242 | }; |
| 1243 | if callee_name != "createApi" && callee_name != "injectEndpoints" { |
| 1244 | return None; |
| 1245 | } |
| 1246 | let args = call.child_by_field_name("arguments")?; |
| 1247 | for i in 0..args.named_child_count() { |
| 1248 | let Some(arg) = args.named_child(i) else { continue }; |
| 1249 | if !matches!(arg.kind(), "object" | "object_expression") { |
| 1250 | continue; |
| 1251 | } |
| 1252 | for j in 0..arg.named_child_count() { |
| 1253 | let Some(member) = arg.named_child(j) else { continue }; |
| 1254 | if member.kind() == "pair" { |
| 1255 | let Some(key) = member.child_by_field_name("key") else { continue }; |
| 1256 | if self.text(key) != "endpoints" { |
| 1257 | continue; |
| 1258 | } |
| 1259 | if let Some(value) = member.child_by_field_name("value") { |
| 1260 | if matches!(value.kind(), "arrow_function" | "function_expression") { |
| 1261 | return self.function_returned_object(value); |
| 1262 | } |
| 1263 | } |
| 1264 | } else if member.kind() == "method_definition" { |
| 1265 | let Some(key) = member.child_by_field_name("name") else { continue }; |
| 1266 | if self.text(key) != "endpoints" { |
| 1267 | continue; |
| 1268 | } |
| 1269 | return self.function_returned_object(member); |
| 1270 | } |
| 1271 | } |
| 1272 | } |
| 1273 | None |
| 1274 | } |
| 1275 | |
| 1276 | fn extract_rtk_endpoints(&mut self, obj: Node<'t>) { |
| 1277 | for i in 0..obj.named_child_count() { |
no test coverage detected