(&self, call: Node<'t>)
| 552 | } |
| 553 | |
| 554 | fn find_rtk_endpoints_object(&self, call: Node<'t>) -> Option<Node<'t>> { |
| 555 | let callee = call.child_by_field_name("function")?; |
| 556 | let callee_name = match callee.kind() { |
| 557 | "identifier" => self.text(callee), |
| 558 | "member_expression" => { |
| 559 | let prop = callee.child_by_field_name("property").unwrap_or(callee); |
| 560 | self.text(prop) |
| 561 | } |
| 562 | _ => "", |
| 563 | }; |
| 564 | if callee_name != "createApi" && callee_name != "injectEndpoints" { |
| 565 | return None; |
| 566 | } |
| 567 | let args = call.child_by_field_name("arguments")?; |
| 568 | for i in 0..args.named_child_count() { |
| 569 | let Some(arg) = args.named_child(i) else { continue }; |
| 570 | if !matches!(arg.kind(), "object" | "object_expression") { |
| 571 | continue; |
| 572 | } |
| 573 | for j in 0..arg.named_child_count() { |
| 574 | let Some(member) = arg.named_child(j) else { continue }; |
| 575 | if member.kind() == "pair" { |
| 576 | let Some(key) = member.child_by_field_name("key") else { continue }; |
| 577 | if self.text(key) != "endpoints" { |
| 578 | continue; |
| 579 | } |
| 580 | if let Some(value) = member.child_by_field_name("value") { |
| 581 | if matches!(value.kind(), "arrow_function" | "function_expression") { |
| 582 | return self.function_returned_object(value); |
| 583 | } |
| 584 | } |
| 585 | } else if member.kind() == "method_definition" { |
| 586 | let Some(key) = member.child_by_field_name("name") else { continue }; |
| 587 | if self.text(key) != "endpoints" { |
| 588 | continue; |
| 589 | } |
| 590 | return self.function_returned_object(member); |
| 591 | } |
| 592 | } |
| 593 | } |
| 594 | None |
| 595 | } |
| 596 | |
| 597 | fn extract_rtk_endpoints(&mut self, obj: Node<'t>) { |
| 598 | for i in 0..obj.named_child_count() { |
no test coverage detected