Lua variable extraction: handle assignment_statement with function-def filtering.
| 9493 | |
| 9494 | // Lua variable extraction: handle assignment_statement with function-def filtering. |
| 9495 | static void extract_lua_vars(CBMExtractCtx *ctx, TSNode node, CBMArena *a) { |
| 9496 | uint32_t n = ts_node_named_child_count(node); |
| 9497 | for (uint32_t i = 0; i < n; i++) { |
| 9498 | TSNode child = ts_node_named_child(node, i); |
| 9499 | if (strcmp(ts_node_type(child), "assignment_statement") != 0) { |
| 9500 | continue; |
| 9501 | } |
| 9502 | TSNode expr_list = cbm_find_child_by_kind(child, "expression_list"); |
| 9503 | if (!ts_node_is_null(expr_list) && ts_node_named_child_count(expr_list) > 0) { |
| 9504 | TSNode val = ts_node_named_child(expr_list, 0); |
| 9505 | if (!ts_node_is_null(val) && strcmp(ts_node_type(val), "function_definition") == 0) { |
| 9506 | continue; |
| 9507 | } |
| 9508 | } |
| 9509 | TSNode vars = ts_node_child_by_field_name(child, TS_FIELD("variables")); |
| 9510 | if (ts_node_is_null(vars)) { |
| 9511 | vars = cbm_find_child_by_kind(child, "variable_list"); |
| 9512 | } |
| 9513 | if (!ts_node_is_null(vars) && ts_node_named_child_count(vars) > 0) { |
| 9514 | TSNode first = ts_node_named_child(vars, 0); |
| 9515 | if (!ts_node_is_null(first)) { |
| 9516 | push_var_def(ctx, cbm_node_text(a, first, ctx->source), node); |
| 9517 | } |
| 9518 | } |
| 9519 | } |
| 9520 | } |
| 9521 | |
| 9522 | // Strip Perl sigil ($, @, %) from name. |
| 9523 | static char *strip_perl_sigil(char *name) { |
no test coverage detected