| 1507 | } |
| 1508 | |
| 1509 | static TSNode call_reference_candidate_site(CBMExtractCtx *ctx, TSNode node, const char *name, |
| 1510 | WalkState *state) { |
| 1511 | if (!ctx || !name || !language_may_stamp_exact_callable_value_candidate(ctx->language)) { |
| 1512 | return (TSNode){0}; |
| 1513 | } |
| 1514 | const char *kind = ts_node_type(node); |
| 1515 | TSTreeCursor *cursor = reset_occurrence_cursor(state, node); |
| 1516 | TSNode parent = {0}; |
| 1517 | const char *parent_field = NULL; |
| 1518 | if (!cursor) { |
| 1519 | usage_slow_parent_fallback_test_note(); |
| 1520 | parent = ts_node_parent(node); |
| 1521 | } else { |
| 1522 | (void)occurrence_parent(cursor, node, &parent, &parent_field); |
| 1523 | } |
| 1524 | bool ts_family = ctx->language == CBM_LANG_JAVASCRIPT || ctx->language == CBM_LANG_TYPESCRIPT || |
| 1525 | ctx->language == CBM_LANG_TSX; |
| 1526 | if (ts_family && strcmp(kind, "property_identifier") == 0 && !ts_node_is_null(parent) && |
| 1527 | strcmp(ts_node_type(parent), "member_expression") == 0) { |
| 1528 | TSNode property = ts_node_child_by_field_name(parent, TS_FIELD("property")); |
| 1529 | TSNode arguments = {0}; |
| 1530 | const char *member_field = NULL; |
| 1531 | if (cursor) { |
| 1532 | (void)occurrence_parent(cursor, parent, &arguments, &member_field); |
| 1533 | } else { |
| 1534 | usage_slow_parent_fallback_test_note(); |
| 1535 | arguments = ts_node_parent(parent); |
| 1536 | } |
| 1537 | return !ts_node_is_null(property) && ts_node_eq(property, node) && |
| 1538 | !ts_node_is_null(arguments) && |
| 1539 | strcmp(ts_node_type(arguments), "arguments") == 0 |
| 1540 | ? node |
| 1541 | : (TSNode){0}; |
| 1542 | } |
| 1543 | if (ctx->language == CBM_LANG_PYTHON && strcmp(kind, "identifier") == 0 && |
| 1544 | !ts_node_is_null(parent) && strcmp(ts_node_type(parent), "attribute") == 0) { |
| 1545 | TSNode attribute = ts_node_child_by_field_name(parent, TS_FIELD("attribute")); |
| 1546 | return !ts_node_is_null(attribute) && ts_node_eq(attribute, node) |
| 1547 | ? python_direct_callable_attribute_site(parent) |
| 1548 | : (TSNode){0}; |
| 1549 | } |
| 1550 | if (ctx->language == CBM_LANG_GO && strcmp(kind, "field_identifier") == 0 && |
| 1551 | !ts_node_is_null(parent) && strcmp(ts_node_type(parent), "selector_expression") == 0) { |
| 1552 | TSNode field = ts_node_child_by_field_name(parent, TS_FIELD("field")); |
| 1553 | return !ts_node_is_null(field) && ts_node_eq(field, node) && |
| 1554 | (cursor ? is_direct_argument_value_cursor(parent, cursor) |
| 1555 | : is_direct_argument_value(parent)) |
| 1556 | ? parent |
| 1557 | : (TSNode){0}; |
| 1558 | } |
| 1559 | if (ctx->language == CBM_LANG_RUST && strcmp(kind, "scoped_identifier") == 0) { |
| 1560 | return is_direct_argument_value_walk(node, state) ? node : (TSNode){0}; |
| 1561 | } |
| 1562 | if (ctx->language == CBM_LANG_CSHARP) { |
| 1563 | return csharp_callable_value_site(node); |
| 1564 | } |
| 1565 | if (strcmp(kind, "identifier") != 0 && strcmp(kind, "simple_identifier") != 0) { |
| 1566 | return (TSNode){0}; |
no test coverage detected