MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / func_node_name

Function func_node_name

internal/cbm/helpers.c:849–891  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

847}
848
849static const char *func_node_name(CBMArena *a, TSNode func_node, const char *source,
850 CBMLanguage lang) {
851 // Wolfram: set_delayed_top/set_top/set_delayed/set — LHS is apply(user_symbol("f"), ...)
852 if (lang == CBM_LANG_WOLFRAM) {
853 const char *nk = ts_node_type(func_node);
854 if (strcmp(nk, "set_delayed_top") == 0 || strcmp(nk, "set_top") == 0 ||
855 strcmp(nk, "set_delayed") == 0 || strcmp(nk, "set") == 0) {
856 if (ts_node_named_child_count(func_node) > 0) {
857 TSNode lhs = ts_node_named_child(func_node, 0);
858 if (strcmp(ts_node_type(lhs), "apply") == 0 && ts_node_named_child_count(lhs) > 0) {
859 TSNode head = ts_node_named_child(lhs, 0);
860 if (strcmp(ts_node_type(head), "user_symbol") == 0) {
861 return cbm_node_text(a, head, source);
862 }
863 }
864 }
865 return NULL;
866 }
867 }
868
869 TSNode name_node = ts_node_child_by_field_name(func_node, TS_FIELD("name"));
870 if (!ts_node_is_null(name_node)) {
871 return cbm_node_text(a, name_node, source);
872 }
873 // Arrow functions: check parent variable_declarator
874 if (strcmp(ts_node_type(func_node), "arrow_function") == 0) {
875 TSNode parent = ts_node_parent(func_node);
876 if (!ts_node_is_null(parent) && strcmp(ts_node_type(parent), "variable_declarator") == 0) {
877 TSNode vname = ts_node_child_by_field_name(parent, TS_FIELD("name"));
878 if (!ts_node_is_null(vname)) {
879 return cbm_node_text(a, vname, source);
880 }
881 }
882 }
883 // C/C++/CUDA/GLSL: function_definition carries its name in the declarator chain.
884 if (strcmp(ts_node_type(func_node), "function_definition") == 0) {
885 TSNode dn = cbm_resolve_c_declarator_name_node(func_node);
886 if (!ts_node_is_null(dn)) {
887 return cbm_func_name_node_text(a, dn, source);
888 }
889 }
890 return NULL;
891}
892
893const char *cbm_enclosing_func_qn(CBMArena *a, TSNode node, CBMLanguage lang, const char *source,
894 const char *project, const char *rel_path,

Callers 1

cbm_enclosing_func_qnFunction · 0.85

Calls 3

cbm_node_textFunction · 0.85
cbm_func_name_node_textFunction · 0.85

Tested by

no test coverage detected