Try to emit a usage for a reference node. Returns early if the node should be skipped.
| 2456 | |
| 2457 | // Try to emit a usage for a reference node. Returns early if the node should be skipped. |
| 2458 | static void try_emit_usage(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec, |
| 2459 | bool inside_call, bool inside_import) { |
| 2460 | if (emit_direct_perl_coderef_usage(ctx, node, cbm_enclosing_func_qn_cached(ctx, node), 0)) { |
| 2461 | return; |
| 2462 | } |
| 2463 | if (inside_direct_perl_coderef(ctx, node)) { |
| 2464 | return; |
| 2465 | } |
| 2466 | if (!is_reference_node(node, ctx->language)) { |
| 2467 | return; |
| 2468 | } |
| 2469 | if (is_call_argument_label(node)) { |
| 2470 | return; |
| 2471 | } |
| 2472 | if (inside_call || inside_import) { |
| 2473 | return; |
| 2474 | } |
| 2475 | if (is_binding_occurrence(ctx, node, spec, NULL) || |
| 2476 | is_write_occurrence(ctx, node, spec, NULL)) { |
| 2477 | return; |
| 2478 | } |
| 2479 | char *name = reference_name(ctx, node); |
| 2480 | if (name && name[0] && !cbm_is_keyword(name, ctx->language)) { |
| 2481 | CBMUsage usage = {0}; |
| 2482 | usage.ref_name = name; |
| 2483 | usage.enclosing_func_qn = cbm_enclosing_func_qn_cached(ctx, node); |
| 2484 | stamp_usage_site(ctx, &usage, node, name, NULL); |
| 2485 | cbm_usages_push(&ctx->result->usages, ctx->arena, usage); |
| 2486 | } |
| 2487 | } |
| 2488 | |
| 2489 | // Iterative usage walker — explicit stack. |
| 2490 | // |
no test coverage detected