MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / collect

Method collect

codegraph-kernel/src/rustlang.rs:719–759  ·  view source on GitHub ↗
(w: &Walker<'t>, n: Node<'t>, prefix: &str, paths: &mut Vec<(String, Node<'t>)>)

Source from the content-addressed store, hash-verified

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);

Callers 15

strip_js_wsFunction · 0.45
flush_value_refsMethod · 0.45
signature_ofMethod · 0.45
visitMethod · 0.45
extract_variableMethod · 0.45
visit_bodyMethod · 0.45
scan_fn_ref_subtreeMethod · 0.45
extract_fieldMethod · 0.45
extract_inheritanceMethod · 0.45
flush_value_refsMethod · 0.45

Calls 2

collectFunction · 0.85
textMethod · 0.45

Tested by

no test coverage detected