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

Method extract_function

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

Source from the content-addressed store, hash-verified

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