MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / try_emit_usage

Function try_emit_usage

internal/cbm/extract_usages.c:2533–2562  ·  view source on GitHub ↗

Try to emit a usage for a reference node. Returns early if the node should be skipped.

Source from the content-addressed store, hash-verified

2531
2532// Try to emit a usage for a reference node. Returns early if the node should be skipped.
2533static 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//

Callers 1

walk_usagesFunction · 0.85

Calls 11

is_reference_nodeFunction · 0.85
is_call_argument_labelFunction · 0.85
is_binding_occurrenceFunction · 0.85
is_write_occurrenceFunction · 0.85
reference_nameFunction · 0.85
cbm_is_keywordFunction · 0.85
stamp_usage_siteFunction · 0.85
cbm_usages_pushFunction · 0.85

Tested by

no test coverage detected