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

Method extract_method_or_function

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

Source from the content-addressed store, hash-verified

695 // --- extractMethod → extractFunction routing (:1737 / :1517) ----------
696
697 fn extract_method_or_function(&mut self, node: Node<'t>) {
698 stack_guard!();
699 // No receiver hook, no methodsAreTopLevel: inside class-like → method,
700 // else → function (the object/object_expression parent check never
701 // matches scala node kinds).
702 let is_method = self.inside_class_like();
703 let name = self.extract_name(node);
704 if name == "<anonymous>" {
705 // Unreachable for scala defs (name field required) — preserved:
706 // walk the body with nothing pushed.
707 if let Some(body) = node.child_by_field_name("body") {
708 self.visit_body(body);
709 }
710 return;
711 }
712 let docstring = preceding_docstring(node, self.src);
713 let signature = self.signature_of(node);
714 let visibility = self.visibility_of(node);
715 let is_static = self.is_static_of(node);
716 let return_type = self.return_type_of(node);
717 let row = self.create_node(
718 if is_method { "method" } else { "function" },
719 &name,
720 node,
721 Extra {
722 docstring,
723 signature,
724 visibility,
725 is_async: Some(false),
726 is_static: Some(is_static),
727 return_type,
728 },
729 );
730 let Some(row) = row else { return };
731 self.extract_type_annotations(node, row);
732 self.extract_decorators_for(node, row);
733 self.stack.push(Scope { row, kind: if is_method { "method" } else { "function" }, name });
734 if let Some(body) = node.child_by_field_name("body") {
735 self.visit_body(body);
736 }
737 self.stack.pop();
738 }
739
740 // --- extractClass (:1679) — classes, objects, traits ------------------
741

Callers 1

visitMethod · 0.80

Calls 11

preceding_docstringFunction · 0.85
inside_class_likeMethod · 0.45
extract_nameMethod · 0.45
visit_bodyMethod · 0.45
signature_ofMethod · 0.45
visibility_ofMethod · 0.45
is_static_ofMethod · 0.45
return_type_ofMethod · 0.45
create_nodeMethod · 0.45

Tested by

no test coverage detected