Push nested class nodes from a class body container onto the defs stack. Iteratively walks into wrapper nodes (field_declaration, template_declaration).
| 11472 | // Push nested class nodes from a class body container onto the defs stack. |
| 11473 | // Iteratively walks into wrapper nodes (field_declaration, template_declaration). |
| 11474 | static void push_nested_class_nodes(TSNode body, const CBMLangSpec *spec, wd_stack_t *s, |
| 11475 | const char *enclosing_qn, const CBMExtractCtx *ctx) { |
| 11476 | TSNodeStack nc_stack; |
| 11477 | ts_nstack_init(&nc_stack, ctx, NESTED_CLASS_STACK_CAP); |
| 11478 | ts_nstack_push(&nc_stack, body); |
| 11479 | |
| 11480 | while (nc_stack.count > 0) { |
| 11481 | TSNode cur = ts_nstack_pop(&nc_stack); |
| 11482 | uint32_t nc = ts_node_child_count(cur); |
| 11483 | /* Linear child access for wide class bodies (see wd_collect_children). */ |
| 11484 | TSNode *kids = wd_collect_children(cur, nc); |
| 11485 | for (int i = (int)nc - SKIP_CHAR; i >= 0; i--) { |
| 11486 | TSNode child = kids ? kids[i] : ts_node_child(cur, (uint32_t)i); |
| 11487 | if (cbm_kind_in_set(child, spec->class_node_types)) { |
| 11488 | wd_push(s, child, enclosing_qn); |
| 11489 | } else { |
| 11490 | const char *ck = ts_node_type(child); |
| 11491 | /* A nested class inside #if/#else is still nested here. */ |
| 11492 | if (strcmp(ck, "field_declaration") == 0 || |
| 11493 | strcmp(ck, "template_declaration") == 0 || strcmp(ck, "declaration") == 0 || |
| 11494 | cbm_kind_in_set(child, cbm_conditional_block_types(spec->language))) { |
| 11495 | ts_nstack_push(&nc_stack, child); |
| 11496 | } |
| 11497 | } |
| 11498 | } |
| 11499 | free(kids); |
| 11500 | } |
| 11501 | } |
| 11502 | |
| 11503 | // Check if a C++/CUDA template_declaration wraps a class/struct/union (not a function). |
| 11504 | static bool is_template_class_node(TSNode node, CBMLanguage lang) { |
no test coverage detected