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

Function resolve_dot_prefix

src/pipeline/pass_pkgmap.c:1051–1081  ·  view source on GitHub ↗

Try dot-based prefix matching (Java: com.myorg.pkg.Foo). * Returns heap QN or NULL. */

Source from the content-addressed store, hash-verified

1049/* Try dot-based prefix matching (Java: com.myorg.pkg.Foo).
1050 * Returns heap QN or NULL. */
1051static char *resolve_dot_prefix(CBMHashTable *map, const char *module_path,
1052 const char *project_name) {
1053 char *buf = strdup(module_path);
1054 if (!buf) {
1055 return NULL;
1056 }
1057 for (char *dot = buf + strlen(buf) - SKIP_ONE; dot > buf; dot--) {
1058 if (*dot != '.') {
1059 continue;
1060 }
1061 *dot = '\0';
1062 const char *base_qn = (const char *)cbm_ht_get(map, buf);
1063 if (!base_qn) {
1064 continue;
1065 }
1066 const char *subpath = module_path + (size_t)(dot - buf) + SKIP_ONE;
1067 char subpath_slashed[PKGMAP_PATH_BUF];
1068 snprintf(subpath_slashed, sizeof(subpath_slashed), "%s", subpath);
1069 for (char *c = subpath_slashed; *c; c++) {
1070 if (*c == '.') {
1071 *c = '/';
1072 }
1073 }
1074 char result[PKGMAP_PATH_BUF];
1075 snprintf(result, sizeof(result), "%s/%s", base_qn, subpath_slashed);
1076 free(buf);
1077 return cbm_pipeline_fqn_module(project_name, result);
1078 }
1079 free(buf);
1080 return NULL;
1081}
1082
1083/* Try backslash-based prefix matching (PHP PSR-4: App\\Controllers\\Foo).
1084 * Returns heap QN or NULL. */

Callers 1

Calls 2

cbm_ht_getFunction · 0.85
cbm_pipeline_fqn_moduleFunction · 0.85

Tested by

no test coverage detected