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

Function describe_callable_reference

internal/cbm/extract_calls.c:4365–4407  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4363}
4364
4365static CBMInvocationDescriptor describe_callable_reference(CBMExtractCtx *ctx, TSNode node) {
4366 CBMInvocationDescriptor descriptor = {0};
4367 descriptor.kind = CBM_INVOCATION_CALLABLE_REFERENCE;
4368 descriptor.site = node;
4369
4370 if (callable_reference_is_branch_alternative(node)) {
4371 return descriptor;
4372 }
4373
4374 uint32_t count = ts_node_named_child_count(node);
4375 if (ctx->language == CBM_LANG_JAVA && count > 0) {
4376 // In `Type::new`, `new` is an unnamed token, so the referenced
4377 // constructor is represented by the left-hand type. For ordinary
4378 // method references, the final named child is the referenced method.
4379 descriptor.callee_expr =
4380 ts_node_named_child(node, node_has_token(node, "new") ? 0 : count - 1);
4381 } else if (ctx->language == CBM_LANG_KOTLIN && count > 0) {
4382 descriptor.callee_expr = ts_node_named_child(node, count - 1);
4383 } else if (ctx->language == CBM_LANG_PHP) {
4384 descriptor.callee_expr = primary_callee_expr(node);
4385 /* `$obj->$method(...)` and its nullsafe/static equivalents evaluate the
4386 * member-name variable; the syntax alone does not prove a callable
4387 * target. Leave the terminal unconsumed so the usage pass records it as
4388 * an ordinary value instead of a CALL_REFERENCE. A bare typed
4389 * `$handler(...)` remains eligible for PHP-LSP `__invoke` resolution. */
4390 if (php_callable_reference_has_dynamic_member_name(node, descriptor.callee_expr)) {
4391 descriptor.callee_expr = (TSNode){0};
4392 return descriptor;
4393 }
4394 }
4395
4396 if (is_dynamic_callee_expr(ctx, descriptor.callee_expr)) {
4397 descriptor.callee_expr = (TSNode){0};
4398 return descriptor;
4399 }
4400 descriptor.callee_leaf = terminal_callee_leaf(ctx, descriptor.callee_expr);
4401 TSNode name_node =
4402 !ts_node_is_null(descriptor.callee_leaf) ? descriptor.callee_leaf : descriptor.callee_expr;
4403 if (!ts_node_is_null(name_node)) {
4404 descriptor.callee_name = cbm_node_text(ctx->arena, name_node, ctx->source);
4405 }
4406 return descriptor;
4407}
4408
4409static CBMInvocationDescriptor describe_emitted_primary_call(
4410 TSNode node, const CBMPrimaryCalleeSelection *callee) {

Callers 1

handle_callsFunction · 0.85

Calls 7

node_has_tokenFunction · 0.85
primary_callee_exprFunction · 0.85
is_dynamic_callee_exprFunction · 0.85
terminal_callee_leafFunction · 0.85
cbm_node_textFunction · 0.85

Tested by

no test coverage detected