Resolve the QN of an ObjectScript method/classmethod/query node for scope tracking.
| 652 | |
| 653 | // Resolve the QN of an ObjectScript method/classmethod/query node for scope tracking. |
| 654 | static const char *objectscript_get_method_qn(CBMExtractCtx *ctx, TSNode node, |
| 655 | const char *enclosing_class_qn) { |
| 656 | const char *nk = ts_node_type(node); |
| 657 | if (strcmp(nk, "query") == 0) { |
| 658 | TSNode query_name = cbm_find_child_by_kind(node, "query_name"); |
| 659 | if (ts_node_is_null(query_name)) { |
| 660 | return NULL; |
| 661 | } |
| 662 | char *name = cbm_node_text(ctx->arena, query_name, ctx->source); |
| 663 | if (!name || !name[0]) { |
| 664 | return NULL; |
| 665 | } |
| 666 | return enclosing_class_qn ? cbm_arena_sprintf(ctx->arena, "%s.%s", enclosing_class_qn, name) |
| 667 | : cbm_fqn_compute(ctx->arena, ctx->project, ctx->rel_path, name); |
| 668 | } |
| 669 | if (strcmp(nk, "method") != 0 && strcmp(nk, "classmethod") != 0) { |
| 670 | return NULL; |
| 671 | } |
| 672 | for (uint32_t i = 0; i < ts_node_named_child_count(node); i++) { |
| 673 | TSNode child = ts_node_named_child(node, i); |
| 674 | if (strcmp(ts_node_type(child), "method_definition") == 0) { |
| 675 | for (uint32_t j = 0; j < ts_node_named_child_count(child); j++) { |
| 676 | TSNode mchild = ts_node_named_child(child, j); |
| 677 | if (strcmp(ts_node_type(mchild), "method_name") == 0) { |
| 678 | if (ts_node_named_child_count(mchild) > 0) { |
| 679 | TSNode ident = ts_node_named_child(mchild, 0); |
| 680 | char *name = cbm_node_text(ctx->arena, ident, ctx->source); |
| 681 | if (name && name[0]) { |
| 682 | if (enclosing_class_qn) { |
| 683 | return cbm_arena_sprintf(ctx->arena, "%s.%s", enclosing_class_qn, |
| 684 | name); |
| 685 | } |
| 686 | return cbm_fqn_compute(ctx->arena, ctx->project, ctx->rel_path, name); |
| 687 | } |
| 688 | } |
| 689 | } |
| 690 | } |
| 691 | } |
| 692 | } |
| 693 | return NULL; |
| 694 | } |
| 695 | |
| 696 | // Compute function QN for scope tracking (mirrors cbm_enclosing_func_qn logic). |
| 697 | static const char *compute_func_qn(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec, |
no test coverage detected