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

Method extract_function

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

Source from the content-addressed store, hash-verified

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

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