C# variable extraction: handle field_declaration with nested variable_declaration.
| 9002 | |
| 9003 | // C# variable extraction: handle field_declaration with nested variable_declaration. |
| 9004 | static void extract_csharp_vars(CBMExtractCtx *ctx, TSNode node, CBMArena *a) { |
| 9005 | const char *fname = extract_java_field_name(a, node, ctx->source); |
| 9006 | if (fname) { |
| 9007 | push_var_def(ctx, fname, node); |
| 9008 | return; |
| 9009 | } |
| 9010 | /* All declarators have this field as their documentation anchor. Keep one |
| 9011 | * immutable arena string, while each variable retains its own identity: |
| 9012 | * the doc-link driver takes the references of that one text once, from |
| 9013 | * the first declarator. A text that could not be collected whole is no |
| 9014 | * doc of any of them (doc_lost has marked the file's doc links failed); |
| 9015 | * it is not looked up again per declarator. */ |
| 9016 | bool complete = false; |
| 9017 | const char *doc = extract_member_docstring_status(ctx, node, &complete); |
| 9018 | if (!complete) { |
| 9019 | doc = NULL; |
| 9020 | } |
| 9021 | uint32_t n = ts_node_named_child_count(node); |
| 9022 | for (uint32_t i = 0; i < n; i++) { |
| 9023 | TSNode child = ts_node_named_child(node, i); |
| 9024 | if (strcmp(ts_node_type(child), "variable_declaration") != 0) { |
| 9025 | continue; |
| 9026 | } |
| 9027 | uint32_t nc = ts_node_named_child_count(child); |
| 9028 | for (uint32_t j = 0; j < nc; j++) { |
| 9029 | TSNode decl = ts_node_named_child(child, j); |
| 9030 | if (strcmp(ts_node_type(decl), "variable_declarator") == 0) { |
| 9031 | TSNode id = ts_node_child_by_field_name(decl, TS_FIELD("name")); |
| 9032 | if (ts_node_is_null(id)) { |
| 9033 | id = cbm_find_child_by_kind(decl, "identifier"); |
| 9034 | } |
| 9035 | if (!ts_node_is_null(id)) { |
| 9036 | const char *name = cbm_node_text(a, id, ctx->source); |
| 9037 | push_var_def_qn_doc(ctx, name, NULL, decl, doc); |
| 9038 | } |
| 9039 | } |
| 9040 | } |
| 9041 | } |
| 9042 | } |
| 9043 | |
| 9044 | /* Check if a tree-sitter node type is an enum member declaration. */ |
| 9045 | static bool is_enum_member_kind(const char *kind) { |
no test coverage detected