| 608 | } |
| 609 | |
| 610 | static bool is_elixir_def_binding(CBMExtractCtx *ctx, TSNode node) { |
| 611 | for (TSNode form = ts_node_parent(node); !ts_node_is_null(form); form = ts_node_parent(form)) { |
| 612 | if (strcmp(ts_node_type(form), "call") != 0 || ts_node_named_child_count(form) < 2) { |
| 613 | continue; |
| 614 | } |
| 615 | TSNode head = ts_node_named_child(form, 0); |
| 616 | if (!text_equals(ctx, head, "def") && !text_equals(ctx, head, "defp") && |
| 617 | !text_equals(ctx, head, "defmacro")) { |
| 618 | continue; |
| 619 | } |
| 620 | TSNode arguments = ts_node_child_by_field_name(form, TS_FIELD("arguments")); |
| 621 | if (ts_node_is_null(arguments) || ts_node_named_child_count(arguments) == 0) { |
| 622 | arguments = ts_node_named_child(form, 1); |
| 623 | } |
| 624 | TSNode signature = ts_node_named_child_count(arguments) > 0 |
| 625 | ? ts_node_named_child(arguments, 0) |
| 626 | : arguments; |
| 627 | return node_contains(head, node) || node_contains(signature, node); |
| 628 | } |
| 629 | return false; |
| 630 | } |
| 631 | |
| 632 | static bool is_first_named_part_of(TSNode node, const char *container_kind) { |
| 633 | for (TSNode parent = ts_node_parent(node); !ts_node_is_null(parent); |
no test coverage detected