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

Method extract_function

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

Source from the content-addressed store, hash-verified

1264 // --- extractors ----------------------------------------------------------
1265
1266 fn extract_function(&mut self, node: Node<'t>) {
1267 stack_guard!();
1268 // Receiver present (out-of-line `Cls::method` def) → method instead.
1269 if self.variant == Variant::Cpp && self.receiver_type_of(node).is_some() {
1270 self.extract_method(node);
1271 return;
1272 }
1273
1274 let name = self.extract_name(node);
1275 if name == "<anonymous>" {
1276 if let Some(body) = node.child_by_field_name("body") {
1277 self.visit_function_body(body);
1278 }
1279 return;
1280 }
1281 // Misparse artifacts: drop the node, still walk the body (#946/#1061).
1282 if self.is_misparsed_function(&name, node) {
1283 if let Some(body) = node.child_by_field_name("body") {
1284 self.visit_function_body(body);
1285 }
1286 return;
1287 }
1288
1289 let extra = Extra {
1290 docstring: preceding_docstring(node, self.src),
1291 signature: self.constructor_signature(node),
1292 visibility: if self.variant == Variant::Cpp { self.visibility_of(node) } else { None },
1293 return_type: self.return_type_of(node),
1294 ..Extra::default()
1295 };
1296 let Some(row) = self.create_node("function", &name, node, extra) else { return };
1297 // (extractTypeAnnotations + extractDecoratorsFor are structural no-ops
1298 // for c/cpp: not in TYPE_ANNOTATION_LANGUAGES, and the decorator node
1299 // kinds never appear as direct children/preceding siblings in these
1300 // grammars — `attribute` only occurs under attribute_declaration.)
1301 self.stack.push(Scope { row, kind: "function", name, qualified: None });
1302 if let Some(body) = node.child_by_field_name("body") {
1303 self.visit_function_body(body);
1304 }
1305 self.stack.pop();
1306 }
1307
1308 fn extract_method(&mut self, node: Node<'t>) {
1309 stack_guard!();

Callers 3

dispatch_nodeMethod · 0.45
extract_methodMethod · 0.45

Calls 11

preceding_docstringFunction · 0.85
pushMethod · 0.80
receiver_type_ofMethod · 0.45
extract_methodMethod · 0.45
extract_nameMethod · 0.45
visit_function_bodyMethod · 0.45
is_misparsed_functionMethod · 0.45
constructor_signatureMethod · 0.45
visibility_ofMethod · 0.45
return_type_ofMethod · 0.45
create_nodeMethod · 0.45

Tested by

no test coverage detected