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

Function path_last

internal/cbm/extract_imports.c:94–108  ·  view source on GitHub ↗

Helper: get last path component as local name. Recognizes every separator used across the supported import syntaxes: '/' (Go / TS / JS paths), '.' (Java / Kotlin / C# / Python dotted names), '::' (Rust / C++ scope), '\\' (PHP namespaces). The last separator of any kind wins, so "std::collections::HashMap" → "HashMap" and "App\\Http\\Controller" → "Controller".

Source from the content-addressed store, hash-verified

92// kind wins, so "std::collections::HashMap""HashMap" and
93// "App\\Http\\Controller""Controller".
94static const char *path_last(CBMArena *a, const char *path) {
95 if (!path) {
96 return NULL;
97 }
98 const char *last_sep = NULL;
99 for (const char *p = path; *p; p++) {
100 if (*p == '/' || *p == '.' || *p == ':' || *p == '\\') {
101 last_sep = p;
102 }
103 }
104 if (last_sep) {
105 return cbm_arena_strdup(a, last_sep + SKIP_ONE);
106 }
107 return path;
108}
109
110/* An unaliased dotted Python import binds its first component, not its last:
111 * `import xml.etree` introduces `xml`. Keep module_path intact for dependency

Callers 15

parse_go_import_specFunction · 0.85
emit_py_aliased_importFunction · 0.85
process_py_import_fromFunction · 0.85
process_commonjs_requireFunction · 0.85
walk_es_importsFunction · 0.85
parse_java_importsFunction · 0.85
parse_rust_importsFunction · 0.85
parse_c_importsFunction · 0.85
parse_ruby_importsFunction · 0.85
parse_lua_importsFunction · 0.85
r_push_importFunction · 0.85

Calls 1

cbm_arena_strdupFunction · 0.70

Tested by

no test coverage detected