| 552 | } |
| 553 | |
| 554 | static bool is_lisp_def_binding(CBMExtractCtx *ctx, TSNode node) { |
| 555 | bool chialisp = (ctx->language == CBM_LANG_CHIALISP); |
| 556 | for (TSNode form = ts_node_parent(node); !ts_node_is_null(form); form = ts_node_parent(form)) { |
| 557 | const char *kind = ts_node_type(form); |
| 558 | if ((strcmp(kind, "list") != 0 && strcmp(kind, "list_lit") != 0) || |
| 559 | ts_node_named_child_count(form) < 2) { |
| 560 | continue; |
| 561 | } |
| 562 | TSNode head_node = |
| 563 | chialisp ? cbm_lisp_named_child_skip_comments(form, 0) : ts_node_named_child(form, 0); |
| 564 | if (ts_node_is_null(head_node)) { |
| 565 | continue; |
| 566 | } |
| 567 | char *head = cbm_node_text(ctx->arena, head_node, ctx->source); |
| 568 | if (!(chialisp ? cbm_chialisp_is_def_head(head) : lisp_def_head(head))) { |
| 569 | continue; |
| 570 | } |
| 571 | if (node_contains(head_node, node) || named_child_contains(form, 1, node)) { |
| 572 | return true; |
| 573 | } |
| 574 | if ((ctx->language == CBM_LANG_CLOJURE || |
| 575 | (chialisp && chialisp_head_binds_params_at_2(head))) && |
| 576 | ts_node_named_child_count(form) > 2 && named_child_contains(form, 2, node)) { |
| 577 | return true; |
| 578 | } |
| 579 | return false; |
| 580 | } |
| 581 | return false; |
| 582 | } |
| 583 | |
| 584 | static bool is_fennel_fn_binding(CBMExtractCtx *ctx, TSNode node) { |
| 585 | for (TSNode form = ts_node_parent(node); !ts_node_is_null(form); form = ts_node_parent(form)) { |
no test coverage detected