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

Function extract_class_fields

internal/cbm/extract_defs.c:6277–6589  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6275}
6276
6277static void extract_class_fields(CBMExtractCtx *ctx, TSNode class_node, const char *class_qn,
6278 const CBMLangSpec *spec) {
6279 if (!spec->field_node_types || !spec->field_node_types[0]) {
6280 return;
6281 }
6282
6283 TSNode body = find_class_member_body(class_node, ctx->language);
6284 if (ts_node_is_null(body)) {
6285 return;
6286 }
6287
6288 CBMArena *a = ctx->arena;
6289 uint32_t count = ts_node_named_child_count(body);
6290 for (uint32_t i = 0; i < count; i++) {
6291 TSNode child = ts_node_named_child(body, i);
6292
6293 // ObjectScript UDL wraps each member in a class_statement node.
6294 if (ctx->language == CBM_LANG_OBJECTSCRIPT_UDL &&
6295 strcmp(ts_node_type(child), "class_statement") == 0 &&
6296 ts_node_named_child_count(child) > 0) {
6297 child = ts_node_named_child(child, 0);
6298 }
6299
6300 if (!cbm_kind_in_set(child, spec->field_node_types)) {
6301 continue;
6302 }
6303
6304 if (is_func_ptr_field(child)) {
6305 continue;
6306 }
6307
6308 /* Schema/grammar languages (GraphQL/Prisma/Smali) carry the field name on
6309 * a plain child rather than a C-style declarator/type field; handle them
6310 * up front so the generic "type"-field path below doesn't skip them. */
6311 if (extract_schema_field(ctx, child, class_qn)) {
6312 continue;
6313 }
6314
6315 // ObjectScript UDL member extraction. property/parameter -> Variable;
6316 // index/trigger/xdata/storage/foreignkey -> labelled members with
6317 // storage-XML and trigger-body sidecars.
6318 if (ctx->language == CBM_LANG_OBJECTSCRIPT_UDL) {
6319 if (strcmp(ts_node_type(child), "property") == 0 ||
6320 strcmp(ts_node_type(child), "parameter") == 0) {
6321 TSNode pname = cbm_find_child_by_kind(child, "property_name");
6322 if (ts_node_is_null(pname)) {
6323 pname = cbm_find_child_by_kind(child, "parameter_name");
6324 }
6325 if (!ts_node_is_null(pname) && ts_node_named_child_count(pname) > 0) {
6326 TSNode ident = ts_node_named_child(pname, 0);
6327 char *pn = cbm_node_text(a, ident, ctx->source);
6328 if (pn && pn[0]) {
6329 CBMDefinition pdef;
6330 memset(&pdef, 0, sizeof(pdef));
6331 pdef.name = pn;
6332 pdef.qualified_name = cbm_arena_sprintf(a, "%s.%s", class_qn, pn);
6333 pdef.label = "Variable";
6334 pdef.file_path = ctx->rel_path;

Callers 1

extract_class_defFunction · 0.85

Calls 12

find_class_member_bodyFunction · 0.85
cbm_kind_in_setFunction · 0.85
is_func_ptr_fieldFunction · 0.85
extract_schema_fieldFunction · 0.85
cbm_find_child_by_kindFunction · 0.85
cbm_node_textFunction · 0.85
cbm_defs_pushFunction · 0.85
resolve_field_name_nodeFunction · 0.85
cbm_is_exportedFunction · 0.85
cbm_arena_sprintfFunction · 0.70
cbm_arena_strdupFunction · 0.70

Tested by

no test coverage detected