MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / objectscript_get_method_qn

Function objectscript_get_method_qn

internal/cbm/extract_unified.c:654–694  ·  view source on GitHub ↗

Resolve the QN of an ObjectScript method/classmethod/query node for scope tracking.

Source from the content-addressed store, hash-verified

652
653// Resolve the QN of an ObjectScript method/classmethod/query node for scope tracking.
654static 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).
697static const char *compute_func_qn(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec,

Callers 1

compute_func_qnFunction · 0.85

Calls 4

cbm_find_child_by_kindFunction · 0.85
cbm_node_textFunction · 0.85
cbm_fqn_computeFunction · 0.85
cbm_arena_sprintfFunction · 0.70

Tested by

no test coverage detected