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

Method extract_function

codegraph-kernel/src/lua.rs:489–522  ·  view source on GitHub ↗
(&mut self, node: Node<'t>)

Source from the content-addressed store, hash-verified

487 // --- extractFunction / extractMethod (1517 / 1737) --------------------
488
489 fn extract_function(&mut self, node: Node<'t>) {
490 // :1522 receiver short-circuit IS the method routing.
491 if let Some(receiver) = self.receiver_type(node) {
492 let receiver = receiver.to_string();
493 self.extract_method(node, receiver);
494 return;
495 }
496 let name = self.extract_name(node);
497 if name == "<anonymous>" {
498 // Unreachable for function_declaration (grammar requires a name)
499 // but preserved: body walked with nothing pushed.
500 if let Some(body) = node.child_by_field_name("body") {
501 self.visit_body(body);
502 }
503 return;
504 }
505 let docstring = preceding_docstring(node, self.src);
506 let signature = self.signature_of(node);
507 let is_exported = self.is_exported_of(node); // lua None / luau Some(false)
508 let fn_row = self.create_node(
509 "function",
510 &name,
511 node,
512 Extra { docstring, signature, is_exported, ..Default::default() },
513 );
514 let Some(row) = fn_row else { return };
515 // extractTypeAnnotations / extractDecoratorsFor: structurally zero
516 // output for lua/luau (gates + no decorator kinds in scan positions).
517 self.stack.push(Scope { row, kind: "function", name });
518 if let Some(body) = node.child_by_field_name("body") {
519 self.visit_body(body);
520 }
521 self.stack.pop();
522 }
523
524 fn extract_method(&mut self, node: Node<'t>, receiver: String) {
525 let name = self.extract_name(node);

Callers 2

visitMethod · 0.45
visit_bodyMethod · 0.45

Calls 8

preceding_docstringFunction · 0.85
receiver_typeMethod · 0.80
is_exported_ofMethod · 0.80
extract_methodMethod · 0.45
extract_nameMethod · 0.45
visit_bodyMethod · 0.45
signature_ofMethod · 0.45
create_nodeMethod · 0.45

Tested by

no test coverage detected