Try to emit a usage for a reference node. Returns early if the node should be skipped.
| 88 | |
| 89 | // Try to emit a usage for a reference node. Returns early if the node should be skipped. |
| 90 | static void try_emit_usage(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec) { |
| 91 | if (!is_reference_node(node, ctx->language)) { |
| 92 | return; |
| 93 | } |
| 94 | if (is_inside_call(node, spec) || is_inside_import(node, spec)) { |
| 95 | return; |
| 96 | } |
| 97 | if (is_definition_name(node)) { |
| 98 | return; |
| 99 | } |
| 100 | char *name = cbm_node_text(ctx->arena, node, ctx->source); |
| 101 | if (name && name[0] && !cbm_is_keyword(name, ctx->language)) { |
| 102 | CBMUsage usage; |
| 103 | usage.ref_name = name; |
| 104 | usage.enclosing_func_qn = cbm_enclosing_func_qn_cached(ctx, node); |
| 105 | cbm_usages_push(&ctx->result->usages, ctx->arena, usage); |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | // Iterative usage walker — explicit stack |
| 110 | static void walk_usages(CBMExtractCtx *ctx, TSNode root, const CBMLangSpec *spec) { |
no test coverage detected