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

Method extract_method_or_function

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

Source from the content-addressed store, hash-verified

712 // --- extractMethod → extractFunction routing (:1737 / :1517) ----------
713
714 fn extract_method_or_function(&mut self, node: Node<'t>) {
715 stack_guard!();
716 // No receiver hook, no methodsAreTopLevel: inside class-like → method,
717 // else → function (the object/object_expression parent check never
718 // matches scala node kinds).
719 let is_method = self.inside_class_like();
720 let name = self.extract_name(node);
721 if name == "<anonymous>" {
722 // Unreachable for scala defs (name field required) — preserved:
723 // walk the body with nothing pushed.
724 if let Some(body) = node.child_by_field_name("body") {
725 self.visit_body(body);
726 }
727 return;
728 }
729 let docstring = preceding_docstring(node, self.src);
730 let signature = self.signature_of(node);
731 let visibility = self.visibility_of(node);
732 let is_static = self.is_static_of(node);
733 let return_type = self.return_type_of(node);
734 let row = self.create_node(
735 if is_method { "method" } else { "function" },
736 &name,
737 node,
738 Extra {
739 docstring,
740 signature,
741 visibility,
742 is_async: Some(false),
743 is_static: Some(is_static),
744 return_type,
745 },
746 );
747 let Some(row) = row else { return };
748 self.extract_type_annotations(node, row);
749 self.extract_decorators_for(node, row);
750 self.stack.push(Scope { row, kind: if is_method { "method" } else { "function" }, name });
751 if let Some(body) = node.child_by_field_name("body") {
752 self.visit_body(body);
753 }
754 self.stack.pop();
755 }
756
757 // --- extractClass (:1679) — classes, objects, traits ------------------
758

Callers 1

visitMethod · 0.80

Calls 12

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