(w: &Walker<'t>, n: Node<'t>, prefix: &str, paths: &mut Vec<(String, Node<'t>)>)
| 717 | if prefix.is_empty() { seg.to_string() } else { format!("{prefix}::{seg}") } |
| 718 | } |
| 719 | fn collect<'t>(w: &Walker<'t>, n: Node<'t>, prefix: &str, paths: &mut Vec<(String, Node<'t>)>) { |
| 720 | match n.kind() { |
| 721 | "identifier" => paths.push((join(prefix, w.text(n)), n)), |
| 722 | "scoped_identifier" => { |
| 723 | let full = w.text(n).trim(); |
| 724 | paths.push(( |
| 725 | if prefix.is_empty() { full.to_string() } else { format!("{prefix}::{full}") }, |
| 726 | n, |
| 727 | )); |
| 728 | } |
| 729 | "scoped_use_list" => { |
| 730 | let seg = n |
| 731 | .child_by_field_name("path") |
| 732 | .map(|p| w.text(p).trim().to_string()) |
| 733 | .unwrap_or_default(); |
| 734 | let new_prefix = if seg.is_empty() { prefix.to_string() } else { join(prefix, &seg) }; |
| 735 | let list = n.child_by_field_name("list").or_else(|| { |
| 736 | (0..n.named_child_count()) |
| 737 | .filter_map(|i| n.named_child(i)) |
| 738 | .find(|c| c.kind() == "use_list") |
| 739 | }); |
| 740 | if let Some(list) = list { |
| 741 | collect(w, list, &new_prefix, paths); |
| 742 | } |
| 743 | } |
| 744 | "use_list" => { |
| 745 | for i in 0..n.named_child_count() { |
| 746 | if let Some(c) = n.named_child(i) { |
| 747 | collect(w, c, prefix, paths); |
| 748 | } |
| 749 | } |
| 750 | } |
| 751 | "use_as_clause" => { |
| 752 | let p = n.child_by_field_name("path").or_else(|| n.named_child(0)); |
| 753 | if let Some(p) = p { |
| 754 | collect(w, p, prefix, paths); |
| 755 | } |
| 756 | } |
| 757 | _ => {} // visibility_modifier, use_wildcard, bare crate/self/super |
| 758 | } |
| 759 | } |
| 760 | for i in 0..node.named_child_count() { |
| 761 | if let Some(c) = node.named_child(i) { |
| 762 | collect(self, c, "", &mut paths); |
no test coverage detected