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

Method collect

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

825 if prefix.is_empty() { seg.to_string() } else { format!("{prefix}::{seg}") }
826 }
827 fn collect<'t>(w: &Walker<'t>, n: Node<'t>, prefix: &str, paths: &mut Vec<(String, Node<'t>)>) {
828 stack_guard!();
829 match n.kind() {
830 "identifier" => paths.push((join(prefix, w.text(n)), n)),
831 "scoped_identifier" => {
832 let full = w.text(n).trim();
833 paths.push((
834 if prefix.is_empty() { full.to_string() } else { format!("{prefix}::{full}") },
835 n,
836 ));
837 }
838 "scoped_use_list" => {
839 let seg = n
840 .child_by_field_name("path")
841 .map(|p| w.text(p).trim().to_string())
842 .unwrap_or_default();
843 let new_prefix = if seg.is_empty() { prefix.to_string() } else { join(prefix, &seg) };
844 let list = n.child_by_field_name("list").or_else(|| {
845 (0..n.named_child_count())
846 .filter_map(|i| n.named_child(i))
847 .find(|c| c.kind() == "use_list")
848 });
849 if let Some(list) = list {
850 collect(w, list, &new_prefix, paths);
851 }
852 }
853 "use_list" => {
854 for i in 0..n.named_child_count() {
855 if let Some(c) = n.named_child(i) {
856 collect(w, c, prefix, paths);
857 }
858 }
859 }
860 "use_as_clause" => {
861 let p = n.child_by_field_name("path").or_else(|| n.named_child(0));
862 if let Some(p) = p {
863 collect(w, p, prefix, paths);
864 }
865 }
866 _ => {} // visibility_modifier, use_wildcard, bare crate/self/super
867 }
868 }
869 for i in 0..node.named_child_count() {
870 if let Some(c) = node.named_child(i) {
871 collect(self, c, "", &mut paths);

Callers 15

preceding_docstring_withFunction · 0.45
strip_js_wsFunction · 0.45
kotlin_receiver_chainFunction · 0.45
extract_inheritanceMethod · 0.45
flush_value_refsMethod · 0.45
signature_ofMethod · 0.45
visitMethod · 0.45
extract_variableMethod · 0.45
visit_bodyMethod · 0.45

Calls 5

pushMethod · 0.80
mapMethod · 0.80
textMethod · 0.65
joinFunction · 0.50
collectFunction · 0.50

Tested by

no test coverage detected