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

Function cbm_run_php_lsp

internal/cbm/lsp/php_lsp.c:4268–4417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4266/* ── entry: cbm_run_php_lsp ─────────────────────────────────────── */
4267
4268void cbm_run_php_lsp(CBMArena *arena, CBMFileResult *result, const char *source, int source_len,
4269 TSNode root) {
4270 if (!result || !arena || ts_node_is_null(root))
4271 return;
4272
4273 CBMTypeRegistry reg;
4274 cbm_registry_init(&reg, arena);
4275
4276 /* Phase A: register stdlib types/functions. */
4277 cbm_php_stdlib_register(&reg, arena);
4278
4279 const char *module_qn = result->module_qn;
4280
4281 /* Phase B: register types and methods/functions from this file's defs.
4282 * We do not yet know the namespace mapping for the type's QN, so we
4283 * trust the QN that the unified extractor already produced. */
4284 for (int i = 0; i < result->defs.count; i++) {
4285 CBMDefinition *d = &result->defs.items[i];
4286 if (!d->qualified_name || !d->name || !d->label)
4287 continue;
4288
4289 if (strcmp(d->label, "Class") == 0 || strcmp(d->label, "Interface") == 0 ||
4290 strcmp(d->label, "Trait") == 0 || strcmp(d->label, "Enum") == 0 ||
4291 strcmp(d->label, "Type") == 0) {
4292 CBMRegisteredType rt;
4293 memset(&rt, 0, sizeof(rt));
4294 rt.qualified_name = d->qualified_name;
4295 rt.short_name = d->name;
4296 rt.is_interface = (strcmp(d->label, "Interface") == 0);
4297
4298 /* Hoist base_classes as embedded_types so php_lookup_method's
4299 * parent walk works. */
4300 if (d->base_classes) {
4301 int bc = 0;
4302 while (d->base_classes[bc])
4303 bc++;
4304 if (bc > 0) {
4305 const char **emb = (const char **)cbm_arena_alloc(
4306 arena, (size_t)(bc + 1) * sizeof(const char *));
4307 if (emb) {
4308 for (int j = 0; j < bc; j++) {
4309 const char *base = d->base_classes[j];
4310 /* Try same-module, then bare. */
4311 const char *qualified = base;
4312 if (base[0] != '\\' && !strchr(base, '.')) {
4313 qualified = cbm_arena_sprintf(arena, "%s.%s", module_qn, base);
4314 } else if (base[0] == '\\') {
4315 qualified = php_ns_to_dot(arena, base + 1);
4316 } else {
4317 qualified = php_ns_to_dot(arena, base);
4318 }
4319 emb[j] = qualified;
4320 }
4321 emb[bc] = NULL;
4322 rt.embedded_types = emb;
4323 }
4324 }
4325 }

Callers 1

extract_file_ex_bodyFunction · 0.85

Calls 15

cbm_registry_initFunction · 0.85
cbm_php_stdlib_registerFunction · 0.85
php_ns_to_dotFunction · 0.85
cbm_registry_add_typeFunction · 0.85
parse_return_type_textFunction · 0.85
cbm_type_unknownFunction · 0.85
cbm_type_funcFunction · 0.85
cbm_registry_add_funcFunction · 0.85
php_lsp_initFunction · 0.85
cbm_lsp_collect_childrenFunction · 0.85
set_namespace_from_declFunction · 0.85

Tested by

no test coverage detected