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

Function pr_find_func

src/pipeline/doc_links_php.c:805–834  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

803/* ── Functions ───────────────────────────────────────────────────── */
804
805static pr_res_t pr_find_func(const pr_ctx_t *c, const char *fqn, size_t len) {
806 char key[PR_NAME_MAX];
807 if (len >= sizeof(key)) {
808 return pr_mk(PR_NONE);
809 }
810 pr_lower_into(key, fqn, len);
811 void *v = cbm_ht_get(c->ix->func_at, key);
812 int first = v ? (int)((uintptr_t)v - SKIP_ONE) : CBM_NOT_FOUND;
813 int count = 0;
814 int own = CBM_NOT_FOUND;
815 for (int i = first; i >= 0; i = c->ix->funcs[i].next) {
816 count++;
817 own = c->ix->funcs[i].file == c->src ? i : own;
818 }
819 if (count == 0) {
820 return pr_mk(PR_NONE);
821 }
822 if (count > SKIP_ONE && own < 0) {
823 return pr_mk(PR_AMBIGUOUS);
824 }
825 const pr_func_t *fn = &c->ix->funcs[count == SKIP_ONE ? first : own];
826 const pr_file_t *f = &c->ix->files[fn->file];
827 char qn[PR_QN_MAX];
828 int n = snprintf(qn, sizeof(qn), "%s.%s", f->module_qn, fn->name);
829 const cbm_gbuf_node_t *node =
830 (!fn->dup && n > 0 && (size_t)n < sizeof(qn)) ? pr_node(c, qn, f->path) : NULL;
831 pr_res_t r = pr_mk(node ? PR_NODE : PR_GAP);
832 r.node = node;
833 return r;
834}
835
836static pr_res_t pr_function(const pr_ctx_t *c, const pr_ref_t *r) {
837 char fqn[PR_NAME_MAX];

Callers 1

pr_functionFunction · 0.85

Calls 4

pr_mkFunction · 0.85
pr_lower_intoFunction · 0.85
cbm_ht_getFunction · 0.85
pr_nodeFunction · 0.85

Tested by

no test coverage detected