C# variable extraction: handle field_declaration with nested variable_declaration.
| 4545 | |
| 4546 | // C# variable extraction: handle field_declaration with nested variable_declaration. |
| 4547 | static void extract_csharp_vars(CBMExtractCtx *ctx, TSNode node, CBMArena *a) { |
| 4548 | const char *fname = extract_java_field_name(a, node, ctx->source); |
| 4549 | if (fname) { |
| 4550 | push_var_def(ctx, fname, node); |
| 4551 | return; |
| 4552 | } |
| 4553 | uint32_t n = ts_node_named_child_count(node); |
| 4554 | for (uint32_t i = 0; i < n; i++) { |
| 4555 | TSNode child = ts_node_named_child(node, i); |
| 4556 | if (strcmp(ts_node_type(child), "variable_declaration") != 0) { |
| 4557 | continue; |
| 4558 | } |
| 4559 | uint32_t nc = ts_node_named_child_count(child); |
| 4560 | for (uint32_t j = 0; j < nc; j++) { |
| 4561 | TSNode decl = ts_node_named_child(child, j); |
| 4562 | if (strcmp(ts_node_type(decl), "variable_declarator") == 0) { |
| 4563 | TSNode id = ts_node_child_by_field_name(decl, TS_FIELD("name")); |
| 4564 | if (ts_node_is_null(id)) { |
| 4565 | id = cbm_find_child_by_kind(decl, "identifier"); |
| 4566 | } |
| 4567 | if (!ts_node_is_null(id)) { |
| 4568 | push_var_def(ctx, cbm_node_text(a, id, ctx->source), decl); |
| 4569 | } |
| 4570 | } |
| 4571 | } |
| 4572 | } |
| 4573 | } |
| 4574 | |
| 4575 | /* Check if a tree-sitter node type is an enum member declaration. */ |
| 4576 | static bool is_enum_member_kind(const char *kind) { |
no test coverage detected