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

Function func_node_name

internal/cbm/helpers.c:1043–1085  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1041}
1042
1043static const char *func_node_name(CBMArena *a, TSNode func_node, const char *source,
1044 CBMLanguage lang) {
1045 // Wolfram: set_delayed_top/set_top/set_delayed/set — LHS is apply(user_symbol("f"), ...)
1046 if (lang == CBM_LANG_WOLFRAM) {
1047 const char *nk = ts_node_type(func_node);
1048 if (strcmp(nk, "set_delayed_top") == 0 || strcmp(nk, "set_top") == 0 ||
1049 strcmp(nk, "set_delayed") == 0 || strcmp(nk, "set") == 0) {
1050 if (ts_node_named_child_count(func_node) > 0) {
1051 TSNode lhs = ts_node_named_child(func_node, 0);
1052 if (strcmp(ts_node_type(lhs), "apply") == 0 && ts_node_named_child_count(lhs) > 0) {
1053 TSNode head = ts_node_named_child(lhs, 0);
1054 if (strcmp(ts_node_type(head), "user_symbol") == 0) {
1055 return cbm_node_text(a, head, source);
1056 }
1057 }
1058 }
1059 return NULL;
1060 }
1061 }
1062
1063 TSNode name_node = ts_node_child_by_field_name(func_node, TS_FIELD("name"));
1064 if (!ts_node_is_null(name_node)) {
1065 return cbm_node_text(a, name_node, source);
1066 }
1067 // Arrow functions: check parent variable_declarator
1068 if (strcmp(ts_node_type(func_node), "arrow_function") == 0) {
1069 TSNode parent = ts_node_parent(func_node);
1070 if (!ts_node_is_null(parent) && strcmp(ts_node_type(parent), "variable_declarator") == 0) {
1071 TSNode vname = ts_node_child_by_field_name(parent, TS_FIELD("name"));
1072 if (!ts_node_is_null(vname)) {
1073 return cbm_node_text(a, vname, source);
1074 }
1075 }
1076 }
1077 // C/C++/CUDA/GLSL: function_definition carries its name in the declarator chain.
1078 if (strcmp(ts_node_type(func_node), "function_definition") == 0) {
1079 TSNode dn = cbm_resolve_c_declarator_name_node(func_node);
1080 if (!ts_node_is_null(dn)) {
1081 return cbm_func_name_node_text(a, dn, source, lang);
1082 }
1083 }
1084 return NULL;
1085}
1086
1087const char *cbm_enclosing_func_qn(CBMArena *a, TSNode node, CBMLanguage lang, const char *source,
1088 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