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

Function csharp_callable_value_site

internal/cbm/extract_usages.c:1388–1434  ·  view source on GitHub ↗

Direct identifiers and direct, statically-named TS member values passed as * arguments are narrow syntactic candidates only. A language LSP must still * prove one target at this exact occurrence before the graph upgrades USAGE to * CALL_REFERENCE; unresolved, reassigned, and composite expressions stay USAGE. */

Source from the content-addressed store, hash-verified

1386 * prove one target at this exact occurrence before the graph upgrades USAGE to
1387 * CALL_REFERENCE; unresolved, reassigned, and composite expressions stay USAGE. */
1388static TSNode csharp_callable_value_site(TSNode node) {
1389 usage_slow_parent_fallback_test_note();
1390 const char *kind = ts_node_type(node);
1391 if (strcmp(kind, "identifier") != 0 && strcmp(kind, "simple_identifier") != 0) {
1392 return (TSNode){0};
1393 }
1394
1395 TSNode site = node;
1396 TSNode parent = ts_node_parent(site);
1397 if (!ts_node_is_null(parent) && strcmp(ts_node_type(parent), "generic_name") == 0) {
1398 TSNode name = ts_node_child_by_field_name(parent, TS_FIELD("name"));
1399 if (ts_node_is_null(name) && ts_node_named_child_count(parent) > 0) {
1400 name = ts_node_named_child(parent, 0);
1401 }
1402 if (ts_node_is_null(name) || !ts_node_eq(name, node)) {
1403 return (TSNode){0};
1404 }
1405 site = parent;
1406 parent = ts_node_parent(site);
1407 }
1408
1409 if (!ts_node_is_null(parent) && strcmp(ts_node_type(parent), "member_access_expression") == 0) {
1410 TSNode member = ts_node_child_by_field_name(parent, TS_FIELD("name"));
1411 if (ts_node_is_null(member) || !ts_node_eq(member, site)) {
1412 return (TSNode){0};
1413 }
1414 site = parent;
1415 parent = ts_node_parent(site);
1416 }
1417
1418 while (!ts_node_is_null(parent) &&
1419 strcmp(ts_node_type(parent), "parenthesized_expression") == 0) {
1420 TSNode inner = ts_node_child_by_field_name(parent, TS_FIELD("expression"));
1421 if (ts_node_is_null(inner) && ts_node_named_child_count(parent) == 1) {
1422 inner = ts_node_named_child(parent, 0);
1423 }
1424 if (ts_node_is_null(inner) || !ts_node_eq(inner, site)) {
1425 return (TSNode){0};
1426 }
1427 site = parent;
1428 parent = ts_node_parent(site);
1429 }
1430
1431 /* The wrapper chain proves admission, but the semantic row is keyed to the
1432 * terminal method-name identifier. Keep the raw carrier on that leaf. */
1433 return is_direct_argument_value(site) ? node : (TSNode){0};
1434}
1435
1436/* Climb out of the parentheses wrapping a direct argument and return the
1437 * outermost wrapper, or null when the node is not a parenthesised direct

Callers 1

Tested by

no test coverage detected