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

Function jr_parse_java

src/pipeline/doc_links_jvm.c:1631–1684  ·  view source on GitHub ↗

`[module/]Type[#member[(params)]]`, `#member[(params)]`, `member(params)`. */

Source from the content-addressed store, hash-verified

1629
1630/* `[module/]Type[#member[(params)]]`, `#member[(params)]`, `member(params)`. */
1631static bool jr_parse_java(const char *raw, jr_ref_t *r) {
1632 memset(r, 0, sizeof(*r));
1633 size_t len = strlen(raw);
1634 if (len == 0 || len > CBM_DOCLINK_JVM_REF_MAX) {
1635 return false; /* over-long: never resolve a truncated prefix */
1636 }
1637 memcpy(r->text, raw, len + SKIP_ONE);
1638 char *s = r->text;
1639 char *hash = strchr(s, '#');
1640 char *paren = strchr(s, '(');
1641 char *slash = strchr(s, '/');
1642 if (slash && (!hash || slash < hash) && (!paren || slash < paren)) {
1643 s = slash + SKIP_ONE; /* a module prefix */
1644 }
1645 char *type = s;
1646 char *member = NULL;
1647 if (hash) {
1648 *hash = '\0';
1649 member = hash + SKIP_ONE;
1650 } else if (paren) {
1651 member = s; /* `name(..)`: a member of the documented type */
1652 type = NULL;
1653 }
1654 if (member) {
1655 char *mp = strchr(member, '(');
1656 if (mp) {
1657 size_t ml = strlen(mp);
1658 if (mp[ml - SKIP_ONE] != ')' || !jr_parse_params(mp + SKIP_ONE, ml - PAIR_LEN, r)) {
1659 return false; /* a list that does not close, or is longer than any */
1660 }
1661 *mp = '\0';
1662 }
1663 if (!jr_ident(member)) {
1664 return false;
1665 }
1666 r->member = member;
1667 }
1668 if (type) {
1669 /* without type arguments and array brackets */
1670 char *lt = strchr(type, '<');
1671 if (lt) {
1672 *lt = '\0';
1673 }
1674 size_t tl = strlen(type);
1675 while (tl >= PAIR_LEN && type[tl - PAIR_LEN] == '[' && type[tl - SKIP_ONE] == ']') {
1676 tl -= PAIR_LEN;
1677 type[tl] = '\0';
1678 }
1679 if (!jr_split_path(type, r)) {
1680 return false;
1681 }
1682 }
1683 return r->nsegs > 0 || r->member != NULL;
1684}
1685
1686/* A KDoc name: dotted, a segment may be backticked. */
1687static bool jr_parse_kotlin(const char *raw, jr_ref_t *r) {

Callers 1

jr_resolveFunction · 0.85

Calls 3

jr_parse_paramsFunction · 0.85
jr_identFunction · 0.85
jr_split_pathFunction · 0.85

Tested by

no test coverage detected