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

Method collect

codegraph-kernel/src/rustlang.rs:732–773  ·  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

730 if prefix.is_empty() { seg.to_string() } else { format!("{prefix}::{seg}") }
731 }
732 fn collect<'t>(w: &Walker<'t>, n: Node<'t>, prefix: &str, paths: &mut Vec<(String, Node<'t>)>) {
733 stack_guard!();
734 match n.kind() {
735 "identifier" => paths.push((join(prefix, w.text(n)), n)),
736 "scoped_identifier" => {
737 let full = w.text(n).trim();
738 paths.push((
739 if prefix.is_empty() { full.to_string() } else { format!("{prefix}::{full}") },
740 n,
741 ));
742 }
743 "scoped_use_list" => {
744 let seg = n
745 .child_by_field_name("path")
746 .map(|p| w.text(p).trim().to_string())
747 .unwrap_or_default();
748 let new_prefix = if seg.is_empty() { prefix.to_string() } else { join(prefix, &seg) };
749 let list = n.child_by_field_name("list").or_else(|| {
750 (0..n.named_child_count())
751 .filter_map(|i| n.named_child(i))
752 .find(|c| c.kind() == "use_list")
753 });
754 if let Some(list) = list {
755 collect(w, list, &new_prefix, paths);
756 }
757 }
758 "use_list" => {
759 for i in 0..n.named_child_count() {
760 if let Some(c) = n.named_child(i) {
761 collect(w, c, prefix, paths);
762 }
763 }
764 }
765 "use_as_clause" => {
766 let p = n.child_by_field_name("path").or_else(|| n.named_child(0));
767 if let Some(p) = p {
768 collect(w, p, prefix, paths);
769 }
770 }
771 _ => {} // visibility_modifier, use_wildcard, bare crate/self/super
772 }
773 }
774 for i in 0..node.named_child_count() {
775 if let Some(c) = node.named_child(i) {
776 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.65

Tested by

no test coverage detected