| 498 | } |
| 499 | |
| 500 | fn rust_bindings(node: Node<'_>, source: &str, prefix: Option<&str>, result: &mut Vec<String>) { |
| 501 | match node.kind() { |
| 502 | "use_list" => { |
| 503 | for child in named(node) { |
| 504 | rust_bindings(child, source, prefix, result); |
| 505 | } |
| 506 | } |
| 507 | "scoped_use_list" => { |
| 508 | let parent = node |
| 509 | .child_by_field_name("path") |
| 510 | .map(|path| text(path, source)); |
| 511 | for list in named(node) |
| 512 | .into_iter() |
| 513 | .filter(|child| child.kind() == "use_list") |
| 514 | { |
| 515 | rust_bindings(list, source, parent, result); |
| 516 | } |
| 517 | } |
| 518 | "use_as_clause" => { |
| 519 | if let Some(alias) = node.child_by_field_name("alias") { |
| 520 | result.push(text(alias, source).into()); |
| 521 | } |
| 522 | } |
| 523 | "self" => result.push( |
| 524 | prefix |
| 525 | .unwrap_or("self") |
| 526 | .rsplit("::") |
| 527 | .next() |
| 528 | .unwrap_or("self") |
| 529 | .into(), |
| 530 | ), |
| 531 | _ => result.push( |
| 532 | text(node, source) |
| 533 | .rsplit("::") |
| 534 | .next() |
| 535 | .unwrap_or_default() |
| 536 | .trim() |
| 537 | .into(), |
| 538 | ), |
| 539 | } |
| 540 | } |
| 541 | |
| 542 | pub(super) fn dependencies(nodes: &[Node<'_>], source: &str, language: Language) -> Measurement { |
| 543 | let mut units = BTreeSet::new(); |