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(fqn): directory-based module QN for Java/Go (de-double) + nested-class enclosing
Martin Vogelb3b3a489982e
diff --git a/internal/cbm/cbm.c b/internal/cbm/cbm.cindex d611f186f..af4fda31e 100644--- a/internal/cbm/cbm.c+++ b/internal/cbm/cbm.c@@ -565,8 +565,12 @@ CBMFileResult *cbm_extract_file(const char *source, int source_len, CBMLanguageTSNode root = ts_tree_root_node(tree);- // Compute module QN- result->module_qn = cbm_fqn_module(a, project, rel_path);+ // Compute module QN. Java/Go derive the module from the CONTAINING+ // DIRECTORY (package semantics) rather than baking the filename stem in,+ // so def QNs, the LSP caller_qn, and the textual calls-enclosing QN all+ // agree (e.g. Outer.java -> module "proj", not "proj.Outer"). Other+ // languages are unchanged.+ result->module_qn = cbm_fqn_module_source_lang(a, project, rel_path, language);result->is_test_file = cbm_is_test_file(rel_path, language);// Build extraction contextdiff --git a/internal/cbm/extract_defs.c b/internal/cbm/extract_defs.cindex 94040369b..ec63922a1 100644--- a/internal/cbm/extract_defs.c+++ b/internal/cbm/extract_defs.c@@ -2879,7 +2879,11 @@ static void extract_func_def(CBMExtractCtx *ctx, TSNode node, const CBMLangSpecmemset(&def, 0, sizeof(def));def.name = name;- def.qualified_name = cbm_fqn_compute(a, ctx->project, ctx->rel_path, name);+ /* Java/Go derive the module from the containing directory (package), so the+ * filename stem is NOT baked into the QN (Go func in myapp/db/conn.go ->+ * proj.myapp.db.Func, not proj.myapp.db.conn.Func). Other langs unchanged. */+ def.qualified_name =+ cbm_fqn_compute_source_lang(a, ctx->project, ctx->rel_path, name, ctx->language);def.label = "Function";def.file_path = ctx->rel_path;def.start_line = ts_node_start_point(node).row + TS_LINE_OFFSET;@@ -2928,7 +2932,10 @@ static void extract_func_def(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec* is computed the same way (cbm_fqn_compute on the type name). */char *recv_type = go_receiver_type_name(a, recv, ctx->source);if (recv_type && recv_type[0]) {- def.parent_class = cbm_fqn_compute(a, ctx->project, ctx->rel_path, recv_type);+ /* Must match the Go type node QN (directory-based module) so the+ * DEFINES_METHOD edge links the method to its owning type. */+ def.parent_class = cbm_fqn_compute_source_lang(a, ctx->project, ctx->rel_path,+ recv_type, ctx->language);}}@@ -3507,12 +3514,15 @@ static void extract_class_def(CBMExtractCtx *ctx, TSNode node, const CBMLangSpecreturn;}- // For nested classes, prefix with enclosing class QN (e.g., Outer.Inner)+ // For nested classes, prefix with enclosing class QN (e.g., Outer.Inner).+ // Top-level classes use the language-aware module QN so Java/Go don't double+ // the filename stem (Java `Outer` in Outer.java -> proj.Outer, not+ // proj.Outer.Outer); the nested prefix then yields proj.Outer.Inner.const char *class_qn;if (ctx->enclosing_class_qn) {class_qn = cbm_arena_sprintf(a, "%s.%s", ctx->enclosing_class_qn, name);} else {- class_qn = cbm_fqn_compute(a, ctx->project, ctx->rel_path, name);+ class_qn = cbm_fqn_compute_source_lang(a, ctx->project, ctx->rel_path, name, ctx->language);}const char *label = class_label_for_kind(kind);@@ -4222,7 +4232,10 @@ static void push_var_def(CBMExtractCtx *ctx, const char *name, TSNode node) {CBMDefinition def;memset(&def, 0, sizeof(def));def.name = name;- def.qualified_name = cbm_fqn_compute(a, ctx->project, ctx->rel_path, name);+ /* Java/Go: directory-based module (package), so a Go package-level var in+ * myapp/db/conn.go is proj.myapp.db.Var, matching its siblings. */+ def.qualified_name =+ cbm_fqn_compute_source_lang(a, ctx->project, ctx->rel_path, name, ctx->language);def.label = "Variable";def.file_path = ctx->rel_path;def.start_line = ts_node_start_point(node).row + TS_LINE_OFFSET;@@ -5439,7 +5452,10 @@ static const char *compute_class_qn(CBMExtractCtx *ctx, TSNode node, const charif (saved_enclosing) {return cbm_arena_sprintf(ctx->arena, "%s.%s", saved_enclosing, cname);}- return cbm_fqn_compute(ctx->arena, ctx->project, ctx->rel_path, cname);+ /* Top-level: language-aware module so Java/Go don't double the+ * filename stem (matches extract_class_def above). */+ return cbm_fqn_compute_source_lang(ctx->arena, ctx->project, ctx->rel_path, cname,+ ctx->language);}}return saved_enclosing;diff --git a/internal/cbm/extract_unified.c b/internal/cbm/extract_unified.cindex a9725b9a1..ad924b77c 100644--- a/internal/cbm/extract_unified.c+++ b/internal/cbm/extract_unified.c@@ -338,11 +338,14 @@ static const char *compute_func_qn(CBMExtractCtx *ctx, TSNode node, const CBMLanif (state->enclosing_class_qn) {return cbm_arena_sprintf(ctx->arena, "%s.%s", state->enclosing_class_qn, name);}- return cbm_fqn_compute(ctx->arena, ctx->project, ctx->rel_path, name);+ /* Java/Go: directory-based module so this enclosing-func QN matches the def+ * QN and the LSP caller_qn (the lsp_resolve join keys on exact equality). */+ return cbm_fqn_compute_source_lang(ctx->arena, ctx->project, ctx->rel_path, name,+ ctx->language);}// Compute class QN for scope tracking.-static const char *compute_class_qn(CBMExtractCtx *ctx, TSNode node) {+static const char *compute_class_qn(CBMExtractCtx *ctx, TSNode node, const WalkState *state) {TSNode name_node = ts_node_child_by_field_name(node, TS_FIELD("name"));/* Newer tree-sitter-kotlin: class/object name is a type_identifier child. */if (ts_node_is_null(name_node) && ctx->language == CBM_LANG_KOTLIN) {@@ -357,7 +360,16 @@ static const char *compute_class_qn(CBMExtractCtx *ctx, TSNode node) {return NULL;}- return cbm_fqn_compute(ctx->arena, ctx->project, ctx->rel_path, name);+ /* Nested class: prefix with the enclosing class QN (Outer.Inner) so this+ * scope QN matches the def-side class QN (extract_defs.c compute_class_qn /+ * extract_class_def), which the lsp_resolve join requires for nested types. */+ if (state && state->enclosing_class_qn) {+ return cbm_arena_sprintf(ctx->arena, "%s.%s", state->enclosing_class_qn, name);+ }++ /* Java/Go: directory-based module (see compute_func_qn). */+ return cbm_fqn_compute_source_lang(ctx->arena, ctx->project, ctx->rel_path, name,+ ctx->language);}/* Forward declaration */@@ -1008,7 +1020,7 @@ static void push_boundary_scopes(CBMExtractCtx *ctx, TSNode node, const CBMLangSpush_scope(state, SCOPE_FUNC, depth, fqn);}} else if (spec->class_node_types && cbm_kind_in_set(node, spec->class_node_types)) {- const char *cqn = compute_class_qn(ctx, node);+ const char *cqn = compute_class_qn(ctx, node, state);if (cqn) {push_scope(state, SCOPE_CLASS, depth, cqn);}diff --git a/internal/cbm/helpers.c b/internal/cbm/helpers.cindex eda44bece..da3fe7f9d 100644--- a/internal/cbm/helpers.c+++ b/internal/cbm/helpers.c@@ -1189,6 +1189,57 @@ char *cbm_fqn_module(CBMArena *a, const char *project, const char *rel_path) {return cbm_fqn_compute(a, project, rel_path, NULL);}+// True when a language derives its module from the CONTAINING DIRECTORY (Java+// package, Go package) rather than baking the filename stem into the module QN.+// For these languages a sibling file in the same dir shares the module, and the+// type/method name is appended once — so a class `Outer` in `Outer.java` is+// `proj.Outer`, not `proj.Outer.Outer`, and a method in `myapp/db/conn.go`+// belongs to module `proj.myapp.db`, not `proj.myapp.db.conn`.+static bool cbm_lang_module_is_dir(CBMLanguage lang) {+ return lang == CBM_LANG_JAVA || lang == CBM_LANG_GO;+}++char *cbm_fqn_module_source_lang(CBMArena *a, const char *project, const char *rel_path,+ CBMLanguage lang) {+ if (!cbm_lang_module_is_dir(lang)) {+ // All other languages keep the legacy filename-stem module QN.+ return cbm_fqn_module(a, project, rel_path);+ }+ if (!rel_path) {+ rel_path = "";+ }+ // Module is the CONTAINING DIRECTORY: strip the basename (last '/' segment).+ const char *last_slash = strrchr(rel_path, '/');+ if (!last_slash) {+ // Root file: dir is empty → module is just the project.+ return cbm_fqn_folder(a, project, "");+ }+ size_t dir_len = (size_t)(last_slash - rel_path);+ char *dir = (char *)cbm_arena_alloc(a, dir_len + SKIP_ONE);+ if (!dir) {+ return NULL;+ }+ memcpy(dir, rel_path, dir_len);+ dir[dir_len] = '\0';+ return cbm_fqn_folder(a, project, dir);+}++char *cbm_fqn_compute_source_lang(CBMArena *a, const char *project, const char *rel_path,+ const char *name, CBMLanguage lang) {+ if (!cbm_lang_module_is_dir(lang)) {+ // All other languages keep the legacy filename-stem symbol QN.+ return cbm_fqn_compute(a, project, rel_path, name);+ }+ char *module = cbm_fqn_module_source_lang(a, project, rel_path, lang);+ if (!module) {+ return NULL;+ }+ if (!name || !name[0]) {+ return module;+ }+ return cbm_arena_sprintf(a, "%s.%s", module, name);+}+char *cbm_fqn_folder(CBMArena *a, const char *project, const char *rel_dir) {// project.dir1.dir2size_t proj_len = strlen(project);diff --git a/internal/cbm/helpers.h b/internal/cbm/helpers.hindex fe22b50d8..99dc140c0 100644--- a/internal/cbm/helpers.h+++ b/internal/cbm/helpers.h@@ -117,6 +117,21 @@ char *cbm_fqn_compute(CBMArena *a, const char *project, const char *rel_path, co// Module QN (file without name): project.rel_path_partschar *cbm_fqn_module(CBMArena *a, const char *project, const char *rel_path);+// Language-aware module QN. For directory-module languages (Java package, Go+// package) the module is derived from the CONTAINING DIRECTORY (the filename+// stem is NOT baked in): `Outer.java` at root -> "proj", `myapp/db/conn.go` ->+// "proj.myapp.db". For every OTHER language this returns exactly what+// cbm_fqn_module returns (no behavior change).+char *cbm_fqn_module_source_lang(CBMArena *a, const char *project, const char *rel_path,+ CBMLanguage lang);++// Language-aware symbol QN. For directory-module languages this is the+// directory-based module + "." + name (so a top-level class `Outer` in+// `Outer.java` is "proj.Outer", not "proj.Outer.Outer"). For every other+// language this is exactly cbm_fqn_compute (no behavior change).+char *cbm_fqn_compute_source_lang(CBMArena *a, const char *project, const char *rel_path,+ const char *name, CBMLanguage lang);+// Folder QN: project.dir_partschar *cbm_fqn_folder(CBMArena *a, const char *project, const char *rel_dir);diff --git a/src/pipeline/fqn.c b/src/pipeline/fqn.cindex c7b8ec470..449bc81ec 100644--- a/src/pipeline/fqn.c+++ b/src/pipeline/fqn.c@@ -126,6 +126,38 @@ char *cbm_pipeline_fqn_module(const char *project, const char *rel_path) {return cbm_pipeline_fqn_compute(project, rel_path, NULL);}+char *cbm_pipeline_fqn_module_dir(const char *project, const char *rel_path, bool module_is_dir) {+ if (!module_is_dir) {+ /* Filename-stem module (default for all but Java/Go). */+ return cbm_pipeline_fqn_module(project, rel_path);+ }+ /* Directory-module languages (Java package, Go package): the module is the+ * CONTAINING DIRECTORY — strip the basename so a sibling file in the same+ * dir shares the module QN. This MUST agree with the extraction-side+ * cbm_fqn_module_source_lang() (internal/cbm/helpers.c) so the cross-file+ * LSP caller_qn matches the def-node QN. */+ const char *src = rel_path ? rel_path : "";+ /* Strip the last path segment using either separator (the extraction side+ * normalizes too); look for the rightmost '/' or '\\'. */+ const char *last_fwd = strrchr(src, '/');+ const char *last_bwd = strrchr(src, '\\');+ const char *last_sep = last_fwd > last_bwd ? last_fwd : last_bwd;+ if (!last_sep) {+ /* Root file: empty directory → module is just the project. */+ return cbm_pipeline_fqn_folder(project, "");+ }+ size_t dir_len = (size_t)(last_sep - src);+ char *dir = (char *)malloc(dir_len + 1); /* +1 for NUL */+ if (!dir) {+ return NULL;+ }+ memcpy(dir, src, dir_len);+ dir[dir_len] = '\0';+ char *res = cbm_pipeline_fqn_folder(project, dir);+ free(dir);+ return res;+}+enum {FQN_PATH_BUF = 1024,FQN_SEP_LEN = 1, /* one byte for the '/' separator */diff --git a/src/pipeline/pass_calls.c b/src/pipeline/pass_calls.cindex 66b94a106..c7c44c998 100644--- a/src/pipeline/pass_calls.c+++ b/src/pipeline/pass_calls.c@@ -33,6 +33,14 @@ enum { PC_RING = 4, PC_RING_MASK = 3, PC_SIG_SCAN = 15, PC_REGEX_GRP = 2 };#include <stdlib.h>#include <string.h>+/* True for languages whose module QN derives from the CONTAINING DIRECTORY+ * (Java/Go package). MUST match cbm_lang_module_is_dir() (internal/cbm/helpers.c)+ * so same-module callee resolution keys against the directory-based def-node+ * QNs in the registry. */+static bool pc_module_is_dir(CBMLanguage lang) {+ return lang == CBM_LANG_JAVA || lang == CBM_LANG_GO;+}+/* Read entire file into heap-allocated buffer. Caller must free(). */static char *read_file(const char *path, int *out_len) {FILE *f = fopen(path, "rb");@@ -563,8 +571,10 @@ int cbm_pipeline_pass_calls(cbm_pipeline_ctx_t *ctx, const cbm_file_info_t *fileint imp_count = 0;build_import_map(ctx, rel, result, &imp_keys, &imp_vals, &imp_count);- /* Compute module QN for same-module resolution */- char *module_qn = cbm_pipeline_fqn_module(ctx->project_name, rel);+ /* Compute module QN for same-module resolution (directory-based for+ * Java/Go so it matches their def-node QNs in the registry). */+ char *module_qn = cbm_pipeline_fqn_module_dir(ctx->project_name, rel,+ pc_module_is_dir(files[i].language));/* Resolve each call */for (int c = 0; c < result->calls.count; c++) {@@ -710,7 +720,8 @@ void cbm_pipeline_pass_fastapi_depends(cbm_pipeline_ctx_t *ctx, const cbm_file_icontinue;}- char *module_qn = cbm_pipeline_fqn_module(ctx->project_name, files[i].rel_path);+ char *module_qn = cbm_pipeline_fqn_module_dir(ctx->project_name, files[i].rel_path,+ pc_module_is_dir(files[i].language));/* Build import map for alias resolution */const char **imp_keys = NULL;diff --git a/src/pipeline/pass_lsp_cross.c b/src/pipeline/pass_lsp_cross.cindex 2f230f3b0..31a7500aa 100644--- a/src/pipeline/pass_lsp_cross.c+++ b/src/pipeline/pass_lsp_cross.c@@ -54,6 +54,15 @@ static const char *itoa_buf(int val) {/* ── Local helpers ─────────────────────────────────────────────── */+/* True for languages whose module QN is derived from the CONTAINING DIRECTORY+ * (Java package, Go package) rather than the filename stem. MUST match the+ * extraction-side cbm_lang_module_is_dir() in internal/cbm/helpers.c so the+ * cross-file LSP caller_qn agrees with the def-node QN (the lsp_resolve join+ * keys on exact equality). */+static bool pxc_module_is_dir(CBMLanguage lang) {+ return lang == CBM_LANG_JAVA || lang == CBM_LANG_GO;+}+/* Slurp a file into a malloc'd, NUL-terminated buffer. Mirrors the* read_file helper in pass_calls.c / pass_parallel.c (kept local so the* pipeline doesn't grow a public read-file API just for this pass). */@@ -178,7 +187,8 @@ CBMLSPDef *cbm_pxc_collect_all_defs(CBMFileResult **cache, const cbm_file_info_tif (!cache[fi])continue;if (!def_modules[fi]) {- def_modules[fi] = cbm_pipeline_fqn_module(project_name, files[fi].rel_path);+ def_modules[fi] = cbm_pipeline_fqn_module_dir(project_name, files[fi].rel_path,+ pxc_module_is_dir(files[fi].language));}for (int di = 0; di < cache[fi]->defs.count; di++) {if (pxc_build_lsp_def(&cache[fi]->arena, &cache[fi]->defs.items[di], def_modules[fi],@@ -579,7 +589,8 @@ int cbm_pipeline_pass_lsp_cross(cbm_pipeline_ctx_t *ctx, const cbm_file_info_t *}if (!def_modules[i]) {- def_modules[i] = cbm_pipeline_fqn_module(ctx->project_name, files[i].rel_path);+ def_modules[i] = cbm_pipeline_fqn_module_dir(ctx->project_name, files[i].rel_path,+ pxc_module_is_dir(files[i].language));}const char **imp_keys = NULL;diff --git a/src/pipeline/pass_parallel.c b/src/pipeline/pass_parallel.cindex 38e5b33eb..5a34e8ef8 100644--- a/src/pipeline/pass_parallel.c+++ b/src/pipeline/pass_parallel.c@@ -391,6 +391,14 @@ static void free_import_map(const char **keys, const char **vals, int count) {}}+/* True for languages whose module QN derives from the CONTAINING DIRECTORY+ * (Java/Go package). MUST match cbm_lang_module_is_dir() (internal/cbm/helpers.c)+ * and pxc_module_is_dir() (pass_lsp_cross.c) so same-module callee resolution+ * keys against the directory-based def-node QNs in the registry. */+static bool pp_module_is_dir(CBMLanguage lang) {+ return lang == CBM_LANG_JAVA || lang == CBM_LANG_GO;+}+static bool is_checked_exception(const char *name) {if (!name) {return false;@@ -2230,7 +2238,8 @@ static void resolve_worker(int worker_id, void *ctx_ptr) {* 98.7% hot spot in resolve_file_calls (881 of 893s CPU). */cbm_registry_resolve_cache_begin(result->calls.count + result->usages.count + 64);- char *module_qn = cbm_pipeline_fqn_module(rc->project_name, rel);+ char *module_qn =+ cbm_pipeline_fqn_module_dir(rc->project_name, rel, pp_module_is_dir(lang));/* ── Cross-file LSP (FUSED) ─────────────────────────────* Runs BEFORE resolve_file_calls so its additions todiff --git a/src/pipeline/pass_semantic.c b/src/pipeline/pass_semantic.cindex affeb9561..3c3c76da7 100644--- a/src/pipeline/pass_semantic.c+++ b/src/pipeline/pass_semantic.c@@ -25,6 +25,14 @@#include <stdlib.h>#include <string.h>+/* True for languages whose module QN derives from the CONTAINING DIRECTORY+ * (Java/Go package). MUST match cbm_lang_module_is_dir() (internal/cbm/helpers.c)+ * so base-class / same-module resolution keys against the directory-based+ * def-node QNs. */+static bool ps_module_is_dir(CBMLanguage lang) {+ return lang == CBM_LANG_JAVA || lang == CBM_LANG_GO;+}+static char *read_file(const char *path, int *out_len) {FILE *f = fopen(path, "rb");if (!f) {@@ -542,7 +550,8 @@ int cbm_pipeline_pass_semantic(cbm_pipeline_ctx_t *ctx, const cbm_file_info_t *fint imp_count = 0;build_import_map(ctx, rel, result, &imp_keys, &imp_vals, &imp_count);- char *module_qn = cbm_pipeline_fqn_module(ctx->project_name, rel);+ char *module_qn = cbm_pipeline_fqn_module_dir(ctx->project_name, rel,+ ps_module_is_dir(files[i].language));/* ── INHERITS + DECORATES from definitions ──────────────── */for (int d = 0; d < result->defs.count; d++) {diff --git a/src/pipeline/pass_usages.c b/src/pipeline/pass_usages.cindex d21048616..7f9c72c82 100644--- a/src/pipeline/pass_usages.c+++ b/src/pipeline/pass_usages.c@@ -24,6 +24,13 @@#include <stdlib.h>#include <string.h>+/* True for languages whose module QN derives from the CONTAINING DIRECTORY+ * (Java/Go package). MUST match cbm_lang_module_is_dir() (internal/cbm/helpers.c)+ * so same-module resolution keys against the directory-based def-node QNs. */+static bool pu_module_is_dir(CBMLanguage lang) {+ return lang == CBM_LANG_JAVA || lang == CBM_LANG_GO;+}+/* Read file into heap buffer. Caller must free(). */static char *read_file(const char *path, int *out_len) {FILE *f = fopen(path, "rb");@@ -355,7 +362,8 @@ int cbm_pipeline_pass_usages(cbm_pipeline_ctx_t *ctx, const cbm_file_info_t *filint imp_count = 0;build_import_map(ctx, rel, result, &imp_keys, &imp_vals, &imp_count);- char *module_qn = cbm_pipeline_fqn_module(ctx->project_name, rel);+ char *module_qn = cbm_pipeline_fqn_module_dir(ctx->project_name, rel,+ pu_module_is_dir(files[i].language));usage_resolved +=resolve_usage_edges(ctx, result, rel, module_qn, imp_keys, imp_vals, imp_count);diff --git a/src/pipeline/pipeline.h b/src/pipeline/pipeline.hindex 7586fa134..4c861e380 100644--- a/src/pipeline/pipeline.h+++ b/src/pipeline/pipeline.h@@ -100,6 +100,12 @@ char *cbm_pipeline_fqn_compute(const char *project, const char *rel_path, const/* Module QN: project.dir.parts (no name). Caller must free(). */char *cbm_pipeline_fqn_module(const char *project, const char *rel_path);+/* Language-aware module QN. When `module_is_dir` is true (Java/Go package+ * semantics) the module is derived from the CONTAINING DIRECTORY (the filename+ * stem is dropped), so it agrees with the extraction-side def QNs; when false+ * it is exactly cbm_pipeline_fqn_module(). Caller must free(). */+char *cbm_pipeline_fqn_module_dir(const char *project, const char *rel_path, bool module_is_dir);+/* Folder QN: project.dir.parts. Caller must free(). */char *cbm_pipeline_fqn_folder(const char *project, const char *rel_dir);diff --git a/tests/test_extraction.c b/tests/test_extraction.cindex d5550ecec..7878d0488 100644--- a/tests/test_extraction.c+++ b/tests/test_extraction.c@@ -2726,6 +2726,101 @@ TEST(extract_java_method_annotations_issue382) {PASS();}+/* Find an in-body call by its raw callee text; returns the call or NULL. */+static const CBMCall *find_call_by_callee(CBMFileResult *r, const char *callee) {+ for (int i = 0; i < r->calls.count; i++) {+ if (r->calls.items[i].callee_name && strcmp(r->calls.items[i].callee_name, callee) == 0) {+ return &r->calls.items[i];+ }+ }+ return NULL;+}++/* Reproduce-first: Java module QN must derive from the CONTAINING DIRECTORY, not+ * the filename stem, so a top-level class `Outer` in `Outer.java` is `t.Outer`,+ * NOT the doubled `t.Outer.Outer`. The nested method def QN must also equal the+ * QN the textual calls-enclosing path records for an in-body call (the+ * lsp_resolve join keys on exact caller_qn == enclosing_func_qn equality). */+TEST(extract_java_no_double_class_qn) {+ CBMFileResult *r = extract("class Outer {\n"+ " int helper(int x) { return x + 2; }\n"+ " class Inner {\n"+ " int run(int v) { return helper(v); }\n"+ " }\n"+ "}\n",+ CBM_LANG_JAVA, "t", "Outer.java");+ ASSERT_NOT_NULL(r);+ ASSERT_FALSE(r->has_error);++ /* Module QN is the directory (root) → just the project. */+ ASSERT_NOT_NULL(r->module_qn);+ ASSERT_STR_EQ(r->module_qn, "t");++ /* No def QN anywhere may double the top-level class name. */+ for (int i = 0; i < r->defs.count; i++) {+ const char *qn = r->defs.items[i].qualified_name;+ if (qn) {+ ASSERT_EQ(strstr(qn, "Outer.Outer"), NULL);+ }+ }++ /* The nested class and its method carry the single-form QN. */+ const CBMDefinition *outer = find_def_by_name(r, "Outer");+ ASSERT_NOT_NULL(outer);+ ASSERT_STR_EQ(outer->qualified_name, "t.Outer");++ const CBMDefinition *run = find_def_by_name(r, "run");+ ASSERT_NOT_NULL(run);+ ASSERT_STR_EQ(run->qualified_name, "t.Outer.Inner.run");++ /* The in-body call to helper() must be attributed to the SAME QN as the+ * method def — this is the equality the LSP cross-resolution join relies on+ * for nested classes (the lsp_outer_dispatch repro). */+ const CBMCall *call = find_call_by_callee(r, "helper");+ ASSERT_NOT_NULL(call);+ ASSERT_NOT_NULL(call->enclosing_func_qn);+ ASSERT_STR_EQ(call->enclosing_func_qn, run->qualified_name);++ cbm_free_result(r);+ PASS();+}++/* Reproduce-first: Go module QN must derive from the CONTAINING DIRECTORY+ * (package), not the filename stem, so a type/method in `myapp/db/conn.go`+ * belongs to module `proj.myapp.db` and is NOT polluted with the `.conn.`+ * filename segment. */+TEST(extract_go_no_filename_in_module_qn) {+ CBMFileResult *r = extract("package db\n\n"+ "type Conn struct{}\n\n"+ "func (c *Conn) Query() {}\n",+ CBM_LANG_GO, "proj", "myapp/db/conn.go");+ ASSERT_NOT_NULL(r);+ ASSERT_FALSE(r->has_error);++ /* Module is the directory `myapp/db`, NOT `myapp/db/conn`. */+ ASSERT_NOT_NULL(r->module_qn);+ ASSERT_STR_EQ(r->module_qn, "proj.myapp.db");++ /* The type and method QNs must not contain the filename segment `.conn.`. */+ const CBMDefinition *conn = find_def_by_name(r, "Conn");+ ASSERT_NOT_NULL(conn);+ ASSERT_STR_EQ(conn->qualified_name, "proj.myapp.db.Conn");++ /* Go method nodes keep a FLAT QN (module + name) with a separate+ * parent_class link to the receiver type — the QN must carry the+ * directory-based module and NOT the `.conn.` filename segment. */+ const CBMDefinition *query = find_def_by_name(r, "Query");+ ASSERT_NOT_NULL(query);+ ASSERT_STR_EQ(query->qualified_name, "proj.myapp.db.Query");+ ASSERT_EQ(strstr(query->qualified_name, ".conn."), NULL);+ /* The method's parent_class must match the type node QN (for DEFINES_METHOD). */+ ASSERT_NOT_NULL(query->parent_class);+ ASSERT_STR_EQ(query->parent_class, "proj.myapp.db.Conn");++ cbm_free_result(r);+ PASS();+}+/* Issue #213: large TS files were indexed as a File node with zero children. */TEST(extract_large_ts_has_functions_issue213) {enum { NFUNCS = 4000 };@@ -3247,6 +3342,8 @@ SUITE(extraction) {RUN_TEST(js_index_module_qn_not_collide_with_folder);RUN_TEST(python_regular_module_qn_unchanged);RUN_TEST(extract_java_method_annotations_issue382);+ RUN_TEST(extract_java_no_double_class_qn);+ RUN_TEST(extract_go_no_filename_in_module_qn);RUN_TEST(extract_large_ts_has_functions_issue213);/* Per-function complexity metrics (Tier A) */