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