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

Function extract_class_fields

internal/cbm/extract_defs.c:10712–11045  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10710}
10711
10712static void extract_class_fields(CBMExtractCtx *ctx, TSNode class_node, const char *class_qn,
10713 const CBMLangSpec *spec) {
10714 if (!spec->field_node_types || !spec->field_node_types[0]) {
10715 return;
10716 }
10717
10718 TSNode body = find_class_member_body(class_node, ctx->language);
10719 if (ctx->language == CBM_LANG_GO) {
10720 body = go_normalize_struct_body(body);
10721 }
10722 if (ts_node_is_null(body)) {
10723 return;
10724 }
10725
10726 CBMArena *a = ctx->arena;
10727 member_iter_t it;
10728 member_iter_init(&it, body, ctx->language, true);
10729 TSNode child;
10730 while (member_iter_next(&it, &child)) {
10731 // ObjectScript UDL wraps each member in a class_statement node.
10732 if (ctx->language == CBM_LANG_OBJECTSCRIPT_UDL &&
10733 strcmp(ts_node_type(child), "class_statement") == 0 &&
10734 ts_node_named_child_count(child) > 0) {
10735 child = ts_node_named_child(child, 0);
10736 }
10737
10738 if (!cbm_kind_in_set(child, spec->field_node_types)) {
10739 continue;
10740 }
10741
10742 if (is_c_member_declaration(ctx, child)) {
10743 extract_c_member_fields(ctx, child, class_qn, spec);
10744 continue;
10745 }
10746
10747 if (is_func_ptr_field(child)) {
10748 continue;
10749 }
10750
10751 /* Schema/grammar languages (GraphQL/Prisma/Smali) carry the field name on
10752 * a plain child rather than a C-style declarator/type field; handle them
10753 * up front so the generic "type"-field path below doesn't skip them. */
10754 if (extract_schema_field(ctx, child, class_qn)) {
10755 continue;
10756 }
10757
10758 // ObjectScript UDL member extraction. property/parameter -> Variable;
10759 // index/trigger/xdata/storage/foreignkey -> labelled members with
10760 // storage-XML and trigger-body sidecars.
10761 if (ctx->language == CBM_LANG_OBJECTSCRIPT_UDL) {
10762 if (strcmp(ts_node_type(child), "property") == 0 ||
10763 strcmp(ts_node_type(child), "parameter") == 0) {
10764 TSNode pname = cbm_find_child_by_kind(child, "property_name");
10765 if (ts_node_is_null(pname)) {
10766 pname = cbm_find_child_by_kind(child, "parameter_name");
10767 }
10768 if (!ts_node_is_null(pname) && ts_node_named_child_count(pname) > 0) {
10769 TSNode ident = ts_node_named_child(pname, 0);

Callers 1

emit_class_defFunction · 0.85

Calls 15

find_class_member_bodyFunction · 0.85
go_normalize_struct_bodyFunction · 0.85
member_iter_initFunction · 0.85
member_iter_nextFunction · 0.85
cbm_kind_in_setFunction · 0.85
is_c_member_declarationFunction · 0.85
extract_c_member_fieldsFunction · 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

Tested by

no test coverage detected