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