| 578 | } |
| 579 | |
| 580 | static bool is_elixir_def_binding(CBMExtractCtx *ctx, TSNode node) { |
| 581 | for (TSNode form = ts_node_parent(node); !ts_node_is_null(form); form = ts_node_parent(form)) { |
| 582 | if (strcmp(ts_node_type(form), "call") != 0 || ts_node_named_child_count(form) < 2) { |
| 583 | continue; |
| 584 | } |
| 585 | TSNode head = ts_node_named_child(form, 0); |
| 586 | if (!text_equals(ctx, head, "def") && !text_equals(ctx, head, "defp") && |
| 587 | !text_equals(ctx, head, "defmacro")) { |
| 588 | continue; |
| 589 | } |
| 590 | TSNode arguments = ts_node_child_by_field_name(form, TS_FIELD("arguments")); |
| 591 | if (ts_node_is_null(arguments) || ts_node_named_child_count(arguments) == 0) { |
| 592 | arguments = ts_node_named_child(form, 1); |
| 593 | } |
| 594 | TSNode signature = ts_node_named_child_count(arguments) > 0 |
| 595 | ? ts_node_named_child(arguments, 0) |
| 596 | : arguments; |
| 597 | return node_contains(head, node) || node_contains(signature, node); |
| 598 | } |
| 599 | return false; |
| 600 | } |
| 601 | |
| 602 | static bool is_first_named_part_of(TSNode node, const char *container_kind) { |
| 603 | for (TSNode parent = ts_node_parent(node); !ts_node_is_null(parent); |
no test coverage detected