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

Method dispatch_node

codegraph-kernel/src/ccpp/mod.rs:1136–1260  ·  view source on GitHub ↗
(&mut self, node: Node<'t>)

Source from the content-addressed store, hash-verified

1134 }
1135
1136 fn dispatch_node(&mut self, node: Node<'t>) {
1137 stack_guard!();
1138 let kind = node.kind();
1139 let mut skip_children = false;
1140
1141 // C/C++ function-like macros become `constant` nodes carrying the
1142 // directive as their signature — a value, never a callee (#1838).
1143 // Mirrors tree-sitter.ts visitNode.
1144 if kind == "preproc_function_def" {
1145 if let Some(name_node) = node.child_by_field_name("name") {
1146 let name = self.text(name_node).to_string();
1147 let signature = Some(self.text(node).trim().to_string());
1148 self.create_node("constant", &name, node, Extra { signature, ..Extra::default() });
1149 }
1150 return;
1151 }
1152
1153 // C++ namespace blocks: prefix-only, no node (#1291/#1093). Anonymous
1154 // namespaces fall through to the generic walk.
1155 if self.variant == Variant::Cpp && kind == "namespace_definition" {
1156 let ns_name = node
1157 .child_by_field_name("name")
1158 .map(|n| self.text(n).to_string())
1159 .unwrap_or_default();
1160 if !ns_name.is_empty() {
1161 self.namespace_prefix.push(ns_name);
1162 for i in 0..node.named_child_count() {
1163 if let Some(c) = node.named_child(i) {
1164 self.visit_node(c);
1165 }
1166 }
1167 self.namespace_prefix.pop();
1168 return;
1169 }
1170 }
1171
1172 self.maybe_capture_fn_refs(node);
1173
1174 if self.is_cpp_constructor_declaration(node) {
1175 self.extract_method(node);
1176 skip_children = true;
1177 } else if kind == "function_definition" {
1178 // functionTypes for both; cpp's methodTypes also lists it, so
1179 // inside a class-like scope it extracts as a method.
1180 if self.inside_class_like() && self.variant == Variant::Cpp {
1181 self.extract_method(node);
1182 } else {
1183 self.extract_function(node);
1184 }
1185 skip_children = true;
1186 } else if self.variant == Variant::Cpp && kind == "class_specifier" {
1187 self.extract_class(node);
1188 skip_children = true;
1189 } else if kind == "struct_specifier" {
1190 self.extract_aggregate(node, "struct");
1191 skip_children = true;
1192 } else if kind == "union_specifier" {
1193 self.extract_aggregate(node, "union");

Callers 2

visit_nodeMethod · 0.80
visit_in_brace_scopeMethod · 0.80

Calls 15

is_class_like_definitionFunction · 0.85
mapMethod · 0.80
pushMethod · 0.80
idMethod · 0.80
textMethod · 0.65
create_nodeMethod · 0.45
visit_nodeMethod · 0.45
maybe_capture_fn_refsMethod · 0.45
extract_methodMethod · 0.45
inside_class_likeMethod · 0.45

Tested by

no test coverage detected