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

Method extract_method_or_function

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

Source from the content-addressed store, hash-verified

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

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