Lua variable extraction: handle assignment_statement with function-def filtering.
| 4754 | |
| 4755 | // Lua variable extraction: handle assignment_statement with function-def filtering. |
| 4756 | static void extract_lua_vars(CBMExtractCtx *ctx, TSNode node, CBMArena *a) { |
| 4757 | uint32_t n = ts_node_named_child_count(node); |
| 4758 | for (uint32_t i = 0; i < n; i++) { |
| 4759 | TSNode child = ts_node_named_child(node, i); |
| 4760 | if (strcmp(ts_node_type(child), "assignment_statement") != 0) { |
| 4761 | continue; |
| 4762 | } |
| 4763 | TSNode expr_list = cbm_find_child_by_kind(child, "expression_list"); |
| 4764 | if (!ts_node_is_null(expr_list) && ts_node_named_child_count(expr_list) > 0) { |
| 4765 | TSNode val = ts_node_named_child(expr_list, 0); |
| 4766 | if (!ts_node_is_null(val) && strcmp(ts_node_type(val), "function_definition") == 0) { |
| 4767 | continue; |
| 4768 | } |
| 4769 | } |
| 4770 | TSNode vars = ts_node_child_by_field_name(child, TS_FIELD("variables")); |
| 4771 | if (ts_node_is_null(vars)) { |
| 4772 | vars = cbm_find_child_by_kind(child, "variable_list"); |
| 4773 | } |
| 4774 | if (!ts_node_is_null(vars) && ts_node_named_child_count(vars) > 0) { |
| 4775 | TSNode first = ts_node_named_child(vars, 0); |
| 4776 | if (!ts_node_is_null(first)) { |
| 4777 | push_var_def(ctx, cbm_node_text(a, first, ctx->source), node); |
| 4778 | } |
| 4779 | } |
| 4780 | } |
| 4781 | } |
| 4782 | |
| 4783 | // Strip Perl sigil ($, @, %) from name. |
| 4784 | static char *strip_perl_sigil(char *name) { |
no test coverage detected