(&self, call: Node<'t>)
| 1128 | } |
| 1129 | |
| 1130 | fn find_rtk_endpoints_object(&self, call: Node<'t>) -> Option<Node<'t>> { |
| 1131 | let callee = call.child_by_field_name("function")?; |
| 1132 | let callee_name = match callee.kind() { |
| 1133 | "identifier" => self.text(callee), |
| 1134 | "member_expression" => { |
| 1135 | let prop = callee.child_by_field_name("property").unwrap_or(callee); |
| 1136 | self.text(prop) |
| 1137 | } |
| 1138 | _ => "", |
| 1139 | }; |
| 1140 | if callee_name != "createApi" && callee_name != "injectEndpoints" { |
| 1141 | return None; |
| 1142 | } |
| 1143 | let args = call.child_by_field_name("arguments")?; |
| 1144 | for i in 0..args.named_child_count() { |
| 1145 | let Some(arg) = args.named_child(i) else { continue }; |
| 1146 | if !matches!(arg.kind(), "object" | "object_expression") { |
| 1147 | continue; |
| 1148 | } |
| 1149 | for j in 0..arg.named_child_count() { |
| 1150 | let Some(member) = arg.named_child(j) else { continue }; |
| 1151 | if member.kind() == "pair" { |
| 1152 | let Some(key) = member.child_by_field_name("key") else { continue }; |
| 1153 | if self.text(key) != "endpoints" { |
| 1154 | continue; |
| 1155 | } |
| 1156 | if let Some(value) = member.child_by_field_name("value") { |
| 1157 | if matches!(value.kind(), "arrow_function" | "function_expression") { |
| 1158 | return self.function_returned_object(value); |
| 1159 | } |
| 1160 | } |
| 1161 | } else if member.kind() == "method_definition" { |
| 1162 | let Some(key) = member.child_by_field_name("name") else { continue }; |
| 1163 | if self.text(key) != "endpoints" { |
| 1164 | continue; |
| 1165 | } |
| 1166 | return self.function_returned_object(member); |
| 1167 | } |
| 1168 | } |
| 1169 | } |
| 1170 | None |
| 1171 | } |
| 1172 | |
| 1173 | fn extract_rtk_endpoints(&mut self, obj: Node<'t>) { |
| 1174 | for i in 0..obj.named_child_count() { |
no test coverage detected