Resolve the QN of an ObjectScript method/classmethod/query node for scope tracking.
| 875 | |
| 876 | // Resolve the QN of an ObjectScript method/classmethod/query node for scope tracking. |
| 877 | static const char *objectscript_get_method_qn(CBMExtractCtx *ctx, TSNode node, |
| 878 | const char *enclosing_class_qn) { |
| 879 | const char *nk = ts_node_type(node); |
| 880 | if (strcmp(nk, "query") == 0) { |
| 881 | TSNode query_name = cbm_find_child_by_kind(node, "query_name"); |
| 882 | if (ts_node_is_null(query_name)) { |
| 883 | return NULL; |
| 884 | } |
| 885 | char *name = cbm_node_text(ctx->arena, query_name, ctx->source); |
| 886 | if (!name || !name[0]) { |
| 887 | return NULL; |
| 888 | } |
| 889 | return enclosing_class_qn ? cbm_arena_sprintf(ctx->arena, "%s.%s", enclosing_class_qn, name) |
| 890 | : cbm_fqn_compute(ctx->arena, ctx->project, ctx->rel_path, name); |
| 891 | } |
| 892 | if (strcmp(nk, "method") != 0 && strcmp(nk, "classmethod") != 0) { |
| 893 | return NULL; |
| 894 | } |
| 895 | for (uint32_t i = 0; i < ts_node_named_child_count(node); i++) { |
| 896 | TSNode child = ts_node_named_child(node, i); |
| 897 | if (strcmp(ts_node_type(child), "method_definition") == 0) { |
| 898 | for (uint32_t j = 0; j < ts_node_named_child_count(child); j++) { |
| 899 | TSNode mchild = ts_node_named_child(child, j); |
| 900 | if (strcmp(ts_node_type(mchild), "method_name") == 0) { |
| 901 | if (ts_node_named_child_count(mchild) > 0) { |
| 902 | TSNode ident = ts_node_named_child(mchild, 0); |
| 903 | char *name = cbm_node_text(ctx->arena, ident, ctx->source); |
| 904 | if (name && name[0]) { |
| 905 | if (enclosing_class_qn) { |
| 906 | return cbm_arena_sprintf(ctx->arena, "%s.%s", enclosing_class_qn, |
| 907 | name); |
| 908 | } |
| 909 | return cbm_fqn_compute(ctx->arena, ctx->project, ctx->rel_path, name); |
| 910 | } |
| 911 | } |
| 912 | } |
| 913 | } |
| 914 | } |
| 915 | } |
| 916 | return NULL; |
| 917 | } |
| 918 | |
| 919 | // Compute function QN for scope tracking (mirrors cbm_enclosing_func_qn logic). |
| 920 | static const char *compute_func_qn(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec, |
no test coverage detected