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

Function push_enum_member

internal/cbm/extract_defs.c:9070–9104  ·  view source on GitHub ↗

One enum member -> a Variable def. `doc_node` is the node whose leading * comments document it: the member itself, or the ERROR that opens its slot * in a macro-wrapped C list (see extract_c_enum_members). */

Source from the content-addressed store, hash-verified

9068 * comments document it: the member itself, or the ERROR that opens its slot
9069 * in a macro-wrapped C list (see extract_c_enum_members). */
9070static void push_enum_member(CBMExtractCtx *ctx, TSNode member, TSNode doc_node,
9071 const enum_member_scope_t *scope) {
9072 CBMArena *a = ctx->arena;
9073 TSNode mname = ts_node_child_by_field_name(member, TS_FIELD("name"));
9074 if (ts_node_is_null(mname)) {
9075 mname = cbm_find_child_by_kind(member, "identifier");
9076 }
9077 if (ts_node_is_null(mname)) {
9078 return;
9079 }
9080 char *member_name = cbm_node_text(a, mname, ctx->source);
9081 if (!member_name || !member_name[0]) {
9082 return;
9083 }
9084 CBMDefinition mdef;
9085 memset(&mdef, 0, sizeof(mdef));
9086 mdef.name = member_name;
9087 if (!scope->flat) {
9088 mdef.qualified_name = cbm_arena_sprintf(a, "%s.%s", scope->class_qn, member_name);
9089 } else if (ctx->enclosing_class_qn && c_enum_scope_is_class(ctx->language)) {
9090 mdef.qualified_name = cbm_arena_sprintf(a, "%s.%s", ctx->enclosing_class_qn, member_name);
9091 } else {
9092 mdef.qualified_name =
9093 cbm_fqn_compute_source_lang(a, ctx->project, ctx->rel_path, member_name, ctx->language);
9094 }
9095 if (scope->c_enum && scope->class_qn) {
9096 mdef.parent_class = scope->class_qn;
9097 }
9098 mdef.label = "Variable";
9099 mdef.file_path = ctx->rel_path;
9100 mdef.start_line = ts_node_start_point(member).row + TS_LINE_OFFSET;
9101 mdef.end_line = ts_node_end_point(member).row + TS_LINE_OFFSET;
9102 mdef.docstring = extract_member_docstring(ctx, doc_node);
9103 cbm_defs_push(&ctx->result->defs, a, mdef);
9104}
9105
9106typedef struct {
9107 int depth; /* parentheses an ERROR child opened and none closed yet */

Callers 2

extract_c_enum_membersFunction · 0.85
extract_enum_membersFunction · 0.85

Calls 7

cbm_find_child_by_kindFunction · 0.85
cbm_node_textFunction · 0.85
c_enum_scope_is_classFunction · 0.85
extract_member_docstringFunction · 0.85
cbm_defs_pushFunction · 0.85
cbm_arena_sprintfFunction · 0.70

Tested by

no test coverage detected