MCPcopy Create free account
hub / github.com/concensure/Semantic / walk_node

Function walk_node

semantic_rust/src/extractor.rs:71–205  ·  view source on GitHub ↗
(
    node: Node<'_>,
    source: &str,
    path: &str,
    module_scope: &[String],
    impl_owner: Option<String>,
    impl_trait: Option<String>,
    symbols: &mut Vec<RustSymbol>,
    imports: &mu

Source from the content-addressed store, hash-verified

69}
70
71fn walk_node(
72 node: Node<'_>,
73 source: &str,
74 path: &str,
75 module_scope: &[String],
76 impl_owner: Option<String>,
77 impl_trait: Option<String>,
78 symbols: &mut Vec<RustSymbol>,
79 imports: &mut Vec<RustImport>,
80 modules: &mut Vec<RustModuleDecl>,
81) {
82 match node.kind() {
83 "struct_item" => {
84 push_named_symbol(node, source, path, module_scope, RustSymbolKind::Struct, symbols)
85 }
86 "enum_item" => {
87 push_named_symbol(node, source, path, module_scope, RustSymbolKind::Enum, symbols)
88 }
89 "trait_item" => {
90 let name = node_name(node, source);
91 push_named_symbol(node, source, path, module_scope, RustSymbolKind::Trait, symbols);
92 let mut cursor = node.walk();
93 for child in node.children(&mut cursor) {
94 walk_node(
95 child,
96 source,
97 path,
98 module_scope,
99 name.clone(),
100 None,
101 symbols,
102 imports,
103 modules,
104 );
105 }
106 return;
107 }
108 "function_item" => {
109 push_function_symbol(
110 node,
111 source,
112 path,
113 module_scope,
114 impl_owner.clone(),
115 impl_trait.clone(),
116 symbols,
117 );
118 }
119 "mod_item" => {
120 let module_name = node_name(node, source);
121 push_named_symbol(node, source, path, module_scope, RustSymbolKind::Module, symbols);
122 modules.push(extract_module_decl(node, source, path));
123 if let Some(module_name) = module_name {
124 let mut nested_scope = module_scope.to_vec();
125 nested_scope.push(module_name);
126 let mut cursor = node.walk();
127 for child in node.children(&mut cursor) {
128 walk_node(

Callers 1

extract_symbolsFunction · 0.85

Calls 10

push_named_symbolFunction · 0.85
node_nameFunction · 0.85
push_function_symbolFunction · 0.85
extract_module_declFunction · 0.85
impl_type_nameFunction · 0.85
impl_trait_nameFunction · 0.85
first_lineFunction · 0.85
module_path_from_scopeFunction · 0.85
extract_importFunction · 0.85
node_textFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…