Try to emit a usage for a reference node. Returns early if the node should be skipped.
| 2531 | |
| 2532 | // Try to emit a usage for a reference node. Returns early if the node should be skipped. |
| 2533 | static void try_emit_usage(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec, |
| 2534 | bool inside_call, bool inside_import) { |
| 2535 | if (emit_direct_perl_coderef_usage(ctx, node, cbm_enclosing_func_qn_cached(ctx, node), 0)) { |
| 2536 | return; |
| 2537 | } |
| 2538 | if (inside_direct_perl_coderef(ctx, node)) { |
| 2539 | return; |
| 2540 | } |
| 2541 | if (!is_reference_node(node, ctx->language)) { |
| 2542 | return; |
| 2543 | } |
| 2544 | if (is_call_argument_label(node)) { |
| 2545 | return; |
| 2546 | } |
| 2547 | if (inside_call || inside_import) { |
| 2548 | return; |
| 2549 | } |
| 2550 | if (is_binding_occurrence(ctx, node, spec, NULL) || |
| 2551 | is_write_occurrence(ctx, node, spec, NULL)) { |
| 2552 | return; |
| 2553 | } |
| 2554 | char *name = reference_name(ctx, node); |
| 2555 | if (name && name[0] && !cbm_is_keyword(name, ctx->language)) { |
| 2556 | CBMUsage usage = {0}; |
| 2557 | usage.ref_name = name; |
| 2558 | usage.enclosing_func_qn = cbm_enclosing_func_qn_cached(ctx, node); |
| 2559 | stamp_usage_site(ctx, &usage, node, name, NULL); |
| 2560 | cbm_usages_push(&ctx->result->usages, ctx->arena, usage); |
| 2561 | } |
| 2562 | } |
| 2563 | |
| 2564 | // Iterative usage walker — explicit stack. |
| 2565 | // |
no test coverage detected