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

Method extract_function

codegraph-kernel/src/ccpp/mod.rs:855–894  ·  view source on GitHub ↗
(&mut self, node: Node<'t>)

Source from the content-addressed store, hash-verified

853 // --- extractors ----------------------------------------------------------
854
855 fn extract_function(&mut self, node: Node<'t>) {
856 stack_guard!();
857 // Receiver present (out-of-line `Cls::method` def) → method instead.
858 if self.variant == Variant::Cpp && self.receiver_type_of(node).is_some() {
859 self.extract_method(node);
860 return;
861 }
862
863 let name = self.extract_name(node);
864 if name == "<anonymous>" {
865 if let Some(body) = node.child_by_field_name("body") {
866 self.visit_function_body(body);
867 }
868 return;
869 }
870 // Misparse artifacts: drop the node, still walk the body (#946/#1061).
871 if self.is_misparsed_function(&name, node) {
872 if let Some(body) = node.child_by_field_name("body") {
873 self.visit_function_body(body);
874 }
875 return;
876 }
877
878 let extra = Extra {
879 docstring: preceding_docstring(node, self.src),
880 visibility: if self.variant == Variant::Cpp { self.visibility_of(node) } else { None },
881 return_type: self.return_type_of(node),
882 ..Extra::default()
883 };
884 let Some(row) = self.create_node("function", &name, node, extra) else { return };
885 // (extractTypeAnnotations + extractDecoratorsFor are structural no-ops
886 // for c/cpp: not in TYPE_ANNOTATION_LANGUAGES, and the decorator node
887 // kinds never appear as direct children/preceding siblings in these
888 // grammars — `attribute` only occurs under attribute_declaration.)
889 self.stack.push(Scope { row, kind: "function", name });
890 if let Some(body) = node.child_by_field_name("body") {
891 self.visit_function_body(body);
892 }
893 self.stack.pop();
894 }
895
896 fn extract_method(&mut self, node: Node<'t>) {
897 stack_guard!();

Callers 3

visit_nodeMethod · 0.45
extract_methodMethod · 0.45

Calls 9

preceding_docstringFunction · 0.85
is_misparsed_functionMethod · 0.80
receiver_type_ofMethod · 0.45
extract_methodMethod · 0.45
extract_nameMethod · 0.45
visit_function_bodyMethod · 0.45
visibility_ofMethod · 0.45
return_type_ofMethod · 0.45
create_nodeMethod · 0.45

Tested by

no test coverage detected