MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / _get_cpp_func_name

Function _get_cpp_func_name

graphify/extractors/engine.py:5115–5139  ·  view source on GitHub ↗

Recursively unwrap declarator to find the innermost identifier (C++).

(node, source: bytes)

Source from the content-addressed store, hash-verified

5113 return True
5114
5115def _get_cpp_func_name(node, source: bytes) -> str | None:
5116 """Recursively unwrap declarator to find the innermost identifier (C++)."""
5117 if node.type == "identifier":
5118 return _read_text(node, source)
5119 if node.type in ("field_identifier", "destructor_name", "operator_name"):
5120 return _read_text(node, source)
5121 if node.type == "qualified_identifier":
5122 # An out-of-class DEFINITION (`void Foo::bar() {}`) carries a
5123 # qualified_identifier declarator. Retaining the `Foo::` qualifier makes
5124 # _make_id(stem, "Foo::bar") normalize to the same id as the in-class
5125 # member _make_id(class_nid, "bar"), so the decl in Foo.h and the def in
5126 # Foo.cpp resolve to ONE method node instead of two (#1547). The full
5127 # qualified text also handles nested scopes (`A::B::bar`). Free functions
5128 # never have a qualified_identifier here, so their bare-name ids are
5129 # unchanged; only qualified definitions shift onto their owning class.
5130 return _read_text(node, source)
5131 decl = node.child_by_field_name("declarator")
5132 if decl:
5133 return _get_cpp_func_name(decl, source)
5134 for child in node.children:
5135 if child.type == "identifier":
5136 return _read_text(child, source)
5137 if child.type == "function_declarator":
5138 return _get_cpp_func_name(child, source)
5139 return None
5140
5141def _cpp_declarator_name(node, source: bytes) -> str | None:
5142 """Return the bare variable name from a C++ declaration declarator, unwrapping

Callers 3

_cpp_member_nidFunction · 0.85
walkFunction · 0.85

Calls 1

_read_textFunction · 0.90

Tested by

no test coverage detected