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

Function extract_enum_members

internal/cbm/extract_defs.c:5214–5247  ·  view source on GitHub ↗

Extract enum members as Variable nodes (C#, Java, TypeScript, C++). */

Source from the content-addressed store, hash-verified

5212
5213/* Extract enum members as Variable nodes (C#, Java, TypeScript, C++). */
5214static void extract_enum_members(CBMExtractCtx *ctx, TSNode node, const char *class_qn) {
5215 CBMArena *a = ctx->arena;
5216 TSNode body = find_class_body(node, ctx->language);
5217 if (ts_node_is_null(body)) {
5218 return;
5219 }
5220 uint32_t mc = ts_node_named_child_count(body);
5221 for (uint32_t mi = 0; mi < mc; mi++) {
5222 TSNode member = ts_node_named_child(body, mi);
5223 if (!is_enum_member_kind(ts_node_type(member))) {
5224 continue;
5225 }
5226 TSNode mname = ts_node_child_by_field_name(member, TS_FIELD("name"));
5227 if (ts_node_is_null(mname)) {
5228 mname = cbm_find_child_by_kind(member, "identifier");
5229 }
5230 if (ts_node_is_null(mname)) {
5231 continue;
5232 }
5233 char *member_name = cbm_node_text(a, mname, ctx->source);
5234 if (!member_name || !member_name[0]) {
5235 continue;
5236 }
5237 CBMDefinition mdef;
5238 memset(&mdef, 0, sizeof(mdef));
5239 mdef.name = member_name;
5240 mdef.qualified_name = cbm_arena_sprintf(a, "%s.%s", class_qn, member_name);
5241 mdef.label = "Variable";
5242 mdef.file_path = ctx->rel_path;
5243 mdef.start_line = ts_node_start_point(member).row + TS_LINE_OFFSET;
5244 mdef.end_line = ts_node_end_point(member).row + TS_LINE_OFFSET;
5245 cbm_defs_push(&ctx->result->defs, a, mdef);
5246 }
5247}
5248
5249/* Resolve the identifier node from a destructure pattern child.
5250 * pair_pattern → value field; shorthand/identifier → itself; others → first named child. */

Callers 1

extract_class_defFunction · 0.85

Calls 6

find_class_bodyFunction · 0.85
is_enum_member_kindFunction · 0.85
cbm_find_child_by_kindFunction · 0.85
cbm_node_textFunction · 0.85
cbm_defs_pushFunction · 0.85
cbm_arena_sprintfFunction · 0.70

Tested by

no test coverage detected