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

Method dispatch_node

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

Source from the content-addressed store, hash-verified

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