(
clause: Node,
source: &str,
file_path: &str,
line_number: i64,
module: &str,
rows: &mut Vec<ImportRow>,
)
| 246 | } |
| 247 | |
| 248 | fn parse_ts_import_clause( |
| 249 | clause: Node, |
| 250 | source: &str, |
| 251 | file_path: &str, |
| 252 | line_number: i64, |
| 253 | module: &str, |
| 254 | rows: &mut Vec<ImportRow>, |
| 255 | ) -> usize { |
| 256 | let mut added = 0usize; |
| 257 | |
| 258 | for child in named_children(clause) { |
| 259 | match child.kind() { |
| 260 | "identifier" => { |
| 261 | added += 1; |
| 262 | rows.push(ImportRow { |
| 263 | file_path: file_path.to_string(), |
| 264 | line_number, |
| 265 | module: module.to_string(), |
| 266 | name: None, |
| 267 | alias: Some(node_text(child, source)), |
| 268 | kind: "import".to_string(), |
| 269 | is_default: true, |
| 270 | is_wildcard: false, |
| 271 | }); |
| 272 | } |
| 273 | "named_imports" => { |
| 274 | for spec in named_children(child).into_iter().filter(|n| n.kind() == "import_specifier") { |
| 275 | let spec_name = spec |
| 276 | .child_by_field_name("name") |
| 277 | .map(|n| clean_identifier(node_text(n, source))); |
| 278 | if spec_name.is_none() { |
| 279 | continue; |
| 280 | } |
| 281 | let alias = spec |
| 282 | .child_by_field_name("alias") |
| 283 | .map(|n| clean_identifier(node_text(n, source))); |
| 284 | |
| 285 | added += 1; |
| 286 | rows.push(ImportRow { |
| 287 | file_path: file_path.to_string(), |
| 288 | line_number, |
| 289 | module: module.to_string(), |
| 290 | name: spec_name, |
| 291 | alias, |
| 292 | kind: "import".to_string(), |
| 293 | is_default: false, |
| 294 | is_wildcard: false, |
| 295 | }); |
| 296 | } |
| 297 | } |
| 298 | "namespace_import" => { |
| 299 | if let Some(alias_node) = named_children(child) |
| 300 | .into_iter() |
| 301 | .find(|n| n.kind() == "identifier") |
| 302 | { |
| 303 | added += 1; |
| 304 | rows.push(ImportRow { |
| 305 | file_path: file_path.to_string(), |
no test coverage detected