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

Function try_emit_usage

internal/cbm/extract_usages.c:2458–2487  ·  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

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

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