Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
fix(lsp): build empty cross-registries for zero-def corpora
Martin Vogel459be8bf570b
diff --git a/internal/cbm/lsp/cs_lsp.c b/internal/cbm/lsp/cs_lsp.cindex 66f41eb09..0beed0a56 100644--- a/internal/cbm/lsp/cs_lsp.c+++ b/internal/cbm/lsp/cs_lsp.c@@ -3714,9 +3714,15 @@ CBMTypeRegistry *cbm_cs_build_cross_registry(CBMArena *arena, CBMLSPDef *defs, i* the type buckets exist, then register FUNCS with O(1) lookups, and* finalize again to index them. Stable order per phase: overload ties* resolve to the first registered QN match. */- CBMLSPDef *cs = (CBMLSPDef *)cbm_arena_alloc(arena, (size_t)def_count * sizeof(*cs));- if (!cs)- return NULL;+ /* def_count == 0 is a valid corpus (no C# files): arena_alloc(0) returns+ * NULL, which must not be mistaken for OOM — the empty registry is still+ * built, finalized, and shared. */+ CBMLSPDef *cs = NULL;+ if (def_count > 0) {+ cs = (CBMLSPDef *)cbm_arena_alloc(arena, (size_t)def_count * sizeof(*cs));+ if (!cs)+ return NULL;+ }int total = 0;for (int i = 0; i < def_count; i++) {if (defs[i].lang == CBM_LANG_CSHARP && cs_def_is_type(&defs[i]))diff --git a/internal/cbm/lsp/java_lsp.c b/internal/cbm/lsp/java_lsp.cindex 6f5d40dd8..9a79783ff 100644--- a/internal/cbm/lsp/java_lsp.c+++ b/internal/cbm/lsp/java_lsp.c@@ -3846,9 +3846,15 @@ CBMTypeRegistry *cbm_java_build_cross_registry(CBMArena *arena, CBMLSPDef *defs,* post-finalize tail stays empty. Bonus over the old one-pass order: a* signature can now resolve a type that appears LATER in defs[], the same* source-order independence the per-file path already guarantees. */- CBMLSPDef *jvm = (CBMLSPDef *)cbm_arena_alloc(arena, (size_t)def_count * sizeof(*jvm));- if (!jvm) {- return NULL;+ /* def_count == 0 is a valid corpus (no Java files): arena_alloc(0) returns+ * NULL, which must not be mistaken for OOM — the empty registry is still+ * built, finalized, and shared. */+ CBMLSPDef *jvm = NULL;+ if (def_count > 0) {+ jvm = (CBMLSPDef *)cbm_arena_alloc(arena, (size_t)def_count * sizeof(*jvm));+ if (!jvm) {+ return NULL;+ }}/* Stable two-pass partition: types in defs[] order, then funcs in defs[]* order. Func registration order is load-bearing — overload ties resolve