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

Function parse_cref

src/pipeline/doc_links_cs.c:3699–3782  ·  view source on GitHub ↗

A written reference into its parts. false for one this code does not * understand -- and for one longer than CS_REF_BUF, which is never cut and * resolved by what is left of it. */

Source from the content-addressed store, hash-verified

3697 * understand -- and for one longer than CS_REF_BUF, which is never cut and
3698 * resolved by what is left of it. */
3699static bool parse_cref(const char *raw, cs_ref_t *r) {
3700 static const char global_prefix[] = "global::";
3701 r->nsegs = 0;
3702 r->nparams = 0;
3703 r->has_params = r->sig_unknown = r->glob = r->op = r->maybe_indexer = r->keyword = false;
3704 r->docid = 0;
3705 r->sig[0] = '\0';
3706 r->op_name[0] = '\0';
3707 const char *in = raw ? raw : "";
3708 while (isspace((unsigned char)*in)) {
3709 in++;
3710 }
3711 size_t n = strlen(in);
3712 while (n > 0 && isspace((unsigned char)in[n - SKIP_ONE])) {
3713 n--;
3714 }
3715 if (n == 0 || n >= sizeof(r->text)) {
3716 return false;
3717 }
3718 memcpy(r->text, in, n);
3719 r->text[n] = '\0';
3720 char *s = r->text;
3721 if (n > PAIR_LEN && s[1] == ':' && strchr("TMPFENO!", s[0])) {
3722 char k = s[0];
3723 if (k == '!') {
3724 return false; /* the compiler's error marker: it could not bind the reference */
3725 }
3726 s += PAIR_LEN;
3727 while (isspace((unsigned char)*s)) {
3728 s++;
3729 }
3730 if (k == 'O') { /* DocFX's overload group: a member without a signature */
3731 char *paren = strchr(s, '(');
3732 if (paren) {
3733 *paren = '\0';
3734 }
3735 }
3736 r->docid = k;
3737 r->glob = true; /* a doc ID is a full name */
3738 }
3739 size_t gl = sizeof(global_prefix) - SKIP_ONE;
3740 if (strncmp(s, global_prefix, gl) == 0) {
3741 r->glob = true;
3742 s += gl;
3743 }
3744 n = strlen(s);
3745 int op = operator_start(s, r->op_name);
3746 if (op >= 0) {
3747 r->op = true;
3748 return op == 0 || parse_path(s, (size_t)op - SKIP_ONE, r->segs, &r->nsegs);
3749 }
3750 /* `Path(params)`: the first top-level parenthesis starts the list. */
3751 size_t paren = n;
3752 int depth = 0;
3753 for (size_t i = 0; i < n; i++) {
3754 char c = s[i];
3755 if (c == '<' || c == '{' || c == '[') {
3756 depth++;

Callers 1

cs_resolveFunction · 0.85

Calls 4

operator_startFunction · 0.85
parse_pathFunction · 0.85
group_endFunction · 0.85
parse_paramsFunction · 0.85

Tested by

no test coverage detected