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

Function push_nested_class_nodes

internal/cbm/extract_defs.c:6739–6764  ·  view source on GitHub ↗

Push nested class nodes from a class body container onto the defs stack. Iteratively walks into wrapper nodes (field_declaration, template_declaration).

Source from the content-addressed store, hash-verified

6737// Push nested class nodes from a class body container onto the defs stack.
6738// Iteratively walks into wrapper nodes (field_declaration, template_declaration).
6739static void push_nested_class_nodes(TSNode body, const CBMLangSpec *spec, wd_stack_t *s,
6740 const char *enclosing_qn, CBMArena *arena) {
6741 TSNodeStack nc_stack;
6742 ts_nstack_init(&nc_stack, arena, NESTED_CLASS_STACK_CAP);
6743 ts_nstack_push(&nc_stack, arena, body);
6744
6745 while (nc_stack.count > 0) {
6746 TSNode cur = ts_nstack_pop(&nc_stack);
6747 uint32_t nc = ts_node_child_count(cur);
6748 /* Linear child access for wide class bodies (see wd_collect_children). */
6749 TSNode *kids = wd_collect_children(cur, nc);
6750 for (int i = (int)nc - SKIP_CHAR; i >= 0; i--) {
6751 TSNode child = kids ? kids[i] : ts_node_child(cur, (uint32_t)i);
6752 if (cbm_kind_in_set(child, spec->class_node_types)) {
6753 wd_push(s, child, enclosing_qn);
6754 } else {
6755 const char *ck = ts_node_type(child);
6756 if (strcmp(ck, "field_declaration") == 0 ||
6757 strcmp(ck, "template_declaration") == 0 || strcmp(ck, "declaration") == 0) {
6758 ts_nstack_push(&nc_stack, arena, child);
6759 }
6760 }
6761 }
6762 free(kids);
6763 }
6764}
6765
6766// Check if a C++/CUDA template_declaration wraps a class/struct/union (not a function).
6767static bool is_template_class_node(TSNode node, CBMLanguage lang) {

Callers 1

push_class_body_childrenFunction · 0.85

Calls 6

ts_nstack_initFunction · 0.85
ts_nstack_pushFunction · 0.85
ts_nstack_popFunction · 0.85
wd_collect_childrenFunction · 0.85
cbm_kind_in_setFunction · 0.85
wd_pushFunction · 0.85

Tested by

no test coverage detected