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

Method extract_function

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

Source from the content-addressed store, hash-verified

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

Callers 2

visitMethod · 0.45
visit_bodyMethod · 0.45

Calls 9

preceding_docstringFunction · 0.85
receiver_typeMethod · 0.80
is_exported_ofMethod · 0.80
pushMethod · 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