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

Function resolve_simple

src/pipeline/doc_links_cs.c:5422–5475  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5420}
5421
5422static cs_res_t resolve_simple(const cs_ctx_t *c, const cs_ref_t *r) {
5423 const cs_seg_t *seg = &r->segs[0];
5424 cs_query_t q = {.name = seg->name, .arity = seg->arity};
5425 cs_found_t fd;
5426 bool statics = false;
5427 lookup(c, &q, &fd, &statics);
5428 if (fd.n > SKIP_ONE) {
5429 return found_ambiguous(&fd);
5430 }
5431 q.statics = statics; /* through a `using static`: its static members are meant */
5432 bool exact = fd.exact && !fd.joined;
5433 cs_use_t u = {.r = r,
5434 .has_params = r->has_params,
5435 .where = {.type_seg = CS_NONE, .member_seg = 0},
5436 .exact = exact};
5437 if (fd.n == 0) {
5438 return fd.invisible ? res_unres(CBM_DOCLINK_REASON_TEST_ONLY) : simple_fallback(c, r, &u);
5439 }
5440 cs_res_t res = res_unres(CBM_DOCLINK_REASON_MISSING);
5441 switch (fd.first.kind) {
5442 case 'L':
5443 /* a type parameter of the definition: no reference to code elsewhere */
5444 return r->has_params ? res : (cs_res_t){.st = CS_LOCAL};
5445 case 'N':
5446 return r->has_params ? res : namespace_result();
5447 case 'T':
5448 if (!r->has_params) {
5449 return type_result(c, fd.first.id, exact);
5450 }
5451 if (fd.exact) {
5452 return res; /* the compiler matches no parameter list against an alias */
5453 }
5454 /* a parameter list on a type's name: its constructor */
5455 u.where = (cs_where_t){.type_seg = 0, .member_seg = CS_NONE};
5456 return ctor_result(c, fd.first.id, &u);
5457 case 'M': {
5458 cs_mb_t st = members_result(c, fd.first.id, &q, &u, &res);
5459 if (st == CS_MB_RES) {
5460 return res;
5461 }
5462 if (st == CS_MB_INVISIBLE) {
5463 return res_unres(CBM_DOCLINK_REASON_TEST_ONLY);
5464 }
5465 /* the level that has the name decides: nothing further out is asked */
5466 if (stub_member(c, fd.first.id, &q, &u, &res) ||
5467 inherited_result(c, fd.first.id, seg, &u, 0, &res)) {
5468 return res;
5469 }
5470 return member_unfound(c, fd.first.id, seg->name, seg->arity);
5471 }
5472 default:
5473 return res_unres(CBM_DOCLINK_REASON_EXTERNAL);
5474 }
5475}
5476
5477/* `Path.Last`: the last segment is a member of what the path before it
5478 * names. Of a type: member_in. Of a namespace: a type (with a parameter

Callers 1

resolve_formFunction · 0.85

Calls 11

lookupFunction · 0.85
found_ambiguousFunction · 0.85
res_unresFunction · 0.85
simple_fallbackFunction · 0.85
namespace_resultFunction · 0.85
type_resultFunction · 0.85
ctor_resultFunction · 0.85
members_resultFunction · 0.85
stub_memberFunction · 0.85
inherited_resultFunction · 0.85
member_unfoundFunction · 0.85

Tested by

no test coverage detected