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

Function cbm_lsp_bare_segment

src/pipeline/lsp_resolve.h:49–65  ·  view source on GitHub ↗

Bare last segment of a (possibly qualified) name, splitting on the LAST * member/scope separator. C++ textual callees carry `::` (Class::method, * Ns::f) and `->` (p->run), while the LSP records dotted internal QNs * (Class.method). Splitting only on '.' (strrchr) leaves `Math::square` * and `p->run` intact, so they never match the LSP's `square`/`run` short * name and the type-aware strategy

Source from the content-addressed store, hash-verified

47 * languages' callee names contain none of `::`/`->`, so this is a no-op
48 * for them. */
49static inline const char *cbm_lsp_bare_segment(const char *name) {
50 if (!name) {
51 return name;
52 }
53 const char *seg = name;
54 for (const char *p = name; *p; p++) {
55 /* '.' (dotted QN / Java-style member) and ':' (C++ `::`, last colon
56 * wins) are member/scope separators. '>' is only a separator when it
57 * closes the `->` arrow (preceded by '-'); a bare '>' closes a template
58 * argument list ("identity<int>") and must NOT split, else the segment
59 * would be the empty string after the trailing '>'. */
60 if (*p == '.' || *p == ':' || (*p == '>' && p != name && p[-1] == '-')) {
61 seg = p + SKIP_ONE;
62 }
63 }
64 return seg;
65}
66
67/* Tail helper: return the start of the final two dot-separated segments
68 * ("Class.method") or NULL when the QN is too short. */

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected