| 1608 | } |
| 1609 | |
| 1610 | static TSNode call_reference_candidate_site(CBMExtractCtx *ctx, TSNode node, const char *name, |
| 1611 | WalkState *state) { |
| 1612 | if (!ctx || !name || !language_may_stamp_exact_callable_value_candidate(ctx->language)) { |
| 1613 | return (TSNode){0}; |
| 1614 | } |
| 1615 | const char *kind = ts_node_type(node); |
| 1616 | TSTreeCursor *cursor = reset_occurrence_cursor(state, node); |
| 1617 | TSNode parent = {0}; |
| 1618 | const char *parent_field = NULL; |
| 1619 | if (!cursor) { |
| 1620 | usage_slow_parent_fallback_test_note(); |
| 1621 | } |
| 1622 | /* Resolve the parent AND the field node occupies in it, on both paths. The |
| 1623 | * C# site walk below carries that field into the argument test, and |
| 1624 | * ts_node_parent on its own would leave it NULL there — silently losing the |
| 1625 | * "this node IS the arguments" case whenever no cursor is available. */ |
| 1626 | (void)occurrence_parent(cursor, node, &parent, &parent_field); |
| 1627 | bool ts_family = ctx->language == CBM_LANG_JAVASCRIPT || ctx->language == CBM_LANG_TYPESCRIPT || |
| 1628 | ctx->language == CBM_LANG_TSX || ctx->language == CBM_LANG_ARKTS; |
| 1629 | if (ts_family && strcmp(kind, "property_identifier") == 0 && !ts_node_is_null(parent) && |
| 1630 | strcmp(ts_node_type(parent), "member_expression") == 0) { |
| 1631 | TSNode property = ts_node_child_by_field_name(parent, TS_FIELD("property")); |
| 1632 | TSNode arguments = {0}; |
| 1633 | const char *member_field = NULL; |
| 1634 | if (cursor) { |
| 1635 | (void)occurrence_parent(cursor, parent, &arguments, &member_field); |
| 1636 | } else { |
| 1637 | usage_slow_parent_fallback_test_note(); |
| 1638 | arguments = ts_node_parent(parent); |
| 1639 | } |
| 1640 | return !ts_node_is_null(property) && ts_node_eq(property, node) && |
| 1641 | !ts_node_is_null(arguments) && |
| 1642 | strcmp(ts_node_type(arguments), "arguments") == 0 |
| 1643 | ? node |
| 1644 | : (TSNode){0}; |
| 1645 | } |
| 1646 | if (ctx->language == CBM_LANG_PYTHON && strcmp(kind, "identifier") == 0 && |
| 1647 | !ts_node_is_null(parent) && strcmp(ts_node_type(parent), "attribute") == 0) { |
| 1648 | TSNode attribute = ts_node_child_by_field_name(parent, TS_FIELD("attribute")); |
| 1649 | return !ts_node_is_null(attribute) && ts_node_eq(attribute, node) |
| 1650 | ? python_direct_callable_attribute_site(parent) |
| 1651 | : (TSNode){0}; |
| 1652 | } |
| 1653 | if (ctx->language == CBM_LANG_GO && strcmp(kind, "field_identifier") == 0 && |
| 1654 | !ts_node_is_null(parent) && strcmp(ts_node_type(parent), "selector_expression") == 0) { |
| 1655 | TSNode field = ts_node_child_by_field_name(parent, TS_FIELD("field")); |
| 1656 | return !ts_node_is_null(field) && ts_node_eq(field, node) && |
| 1657 | (cursor ? is_direct_argument_value_cursor(parent, cursor) |
| 1658 | : is_direct_argument_value(parent)) |
| 1659 | ? parent |
| 1660 | : (TSNode){0}; |
| 1661 | } |
| 1662 | if (ctx->language == CBM_LANG_RUST && strcmp(kind, "scoped_identifier") == 0) { |
| 1663 | return is_direct_argument_value_walk(node, state) ? node : (TSNode){0}; |
| 1664 | } |
| 1665 | if (ctx->language == CBM_LANG_CSHARP) { |
| 1666 | return csharp_callable_value_site(node, parent, parent_field, cursor); |
| 1667 | } |
no test coverage detected