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
Merge main and complete Java record call handling
Martin Vogel321dcb63f9a4
diff --cc internal/cbm/extract_defs.cindex 9a3394294,ddad886af..70ae19bdf--- a/internal/cbm/extract_defs.c+++ b/internal/cbm/extract_defs.c@@@ -4810,11 -8278,8 +8279,12 @@@ static void emit_class_def(CBMExtractCtextract_enum_members(ctx, node, class_qn);}+ if (ctx->language == CBM_LANG_JAVA && strcmp(kind, "record_declaration") == 0) {+ extract_record_accessors(ctx, node, class_qn);+ }+// Extract methods inside the class+ int methods_from = ctx->result->defs.count;extract_class_methods(ctx, node, class_qn, spec);// Extract typed struct/class fields (for cross-file LSP type resolution)@@@ -5686,97 -9532,6 +9537,99 @@@ static void extract_enum_members(CBMExt}}+/* Whether the record body declares this accessor itself (JLS §8.10.3 lets a+ * record override any of them), so the implicit one is not emitted twice. */+static bool record_declares_accessor(CBMExtractCtx *ctx, TSNode node, const char *comp_name) {+ TSNode body = find_class_body(node, ctx->language);+ if (ts_node_is_null(body)) {+ return false;+ }+ uint32_t mc = ts_node_named_child_count(body);+ for (uint32_t mi = 0; mi < mc; mi++) {+ TSNode member = ts_node_named_child(body, mi);+ if (strcmp(ts_node_type(member), "method_declaration") != 0) {+ continue;+ }+ TSNode mname = ts_node_child_by_field_name(member, TS_FIELD("name"));+ if (ts_node_is_null(mname)) {+ continue;+ }+ char *name = cbm_node_text(ctx->arena, mname, ctx->source);+ if (!name || strcmp(name, comp_name) != 0) {+ continue;+ }+ /* Same name, no parameters — that is the accessor. */+ TSNode params = ts_node_child_by_field_name(member, TS_FIELD("parameters"));+ if (ts_node_is_null(params) || ts_node_named_child_count(params) == 0) {+ return true;+ }+ }+ return false;+}++/* Java records: the compiler writes one accessor per component, so `p.x()`+ * calls a method that appears nowhere in the source. Without a definition for+ * it the call has nothing to resolve to and falls through to the project-wide+ * name registry, which binds it to the first `x` in the tree — typically an+ * unrelated class's private field. Emitting the accessors makes the record's+ * own API visible, exactly as the language defines it (JLS §8.10.3). */+static void extract_record_accessors(CBMExtractCtx *ctx, TSNode node, const char *class_qn) {+ CBMArena *a = ctx->arena;+ TSNode params = ts_node_child_by_field_name(node, TS_FIELD("parameters"));+ if (ts_node_is_null(params)) {+ return;+ }+ uint32_t pc = ts_node_named_child_count(params);+ for (uint32_t pi = 0; pi < pc; pi++) {+ TSNode comp = ts_node_named_child(params, pi);- if (strcmp(ts_node_type(comp), "formal_parameter") != 0) {++ bool spread = strcmp(ts_node_type(comp), "spread_parameter") == 0;++ if (!spread && strcmp(ts_node_type(comp), "formal_parameter") != 0) {+ continue;+ }+ TSNode cname = ts_node_child_by_field_name(comp, TS_FIELD("name"));++ TSNode ctype = ts_node_child_by_field_name(comp, TS_FIELD("type"));++ if (spread) {++ /* Java varargs have an unnamed type child and a nested declarator. */++ TSNode decl = cbm_find_child_by_kind(comp, "variable_declarator");++ if (ts_node_is_null(decl)) {++ continue;++ }++ cname = ts_node_child_by_field_name(decl, TS_FIELD("name"));++ uint32_t nc = ts_node_named_child_count(comp);++ for (uint32_t ci = 0; ci < nc; ci++) {++ TSNode child = ts_node_named_child(comp, ci);++ if (!ts_node_is_extra(child) && strcmp(ts_node_type(child), "modifiers") != 0) {++ ctype = child;++ break;++ }++ }++ }+ if (ts_node_is_null(cname)) {+ continue;+ }+ char *comp_name = cbm_node_text(a, cname, ctx->source);+ if (!comp_name || !comp_name[0] || record_declares_accessor(ctx, node, comp_name)) {+ continue;+ }+ CBMDefinition adef;+ memset(&adef, 0, sizeof(adef));+ adef.name = comp_name;+ adef.qualified_name = cbm_arena_sprintf(a, "%s.%s", class_qn, comp_name);+ adef.label = "Method";+ adef.file_path = ctx->rel_path;+ adef.start_line = ts_node_start_point(comp).row + TS_LINE_OFFSET;+ adef.end_line = ts_node_end_point(comp).row + TS_LINE_OFFSET;+ adef.lines = 1;+ adef.parent_class = class_qn;+ adef.is_exported = true;- TSNode ctype = ts_node_child_by_field_name(comp, TS_FIELD("type"));+ if (!ts_node_is_null(ctype)) {- adef.return_type = cbm_node_text(a, ctype, ctx->source);++ const char *type = cbm_node_text(a, ctype, ctx->source);++ adef.return_type = spread && type ? cbm_arena_sprintf(a, "%s[]", type) : type;+ }+ cbm_defs_push(&ctx->result->defs, a, adef);+ }+}+/* Resolve the identifier node from a destructure pattern child.* pair_pattern → value field; shorthand/identifier → itself; others → first named child. */static TSNode destructure_ident(TSNode pat_child) {diff --cc src/pipeline/pass_calls.cindex c702f7efd,f3570904d..64408518c--- a/src/pipeline/pass_calls.c+++ b/src/pipeline/pass_calls.c@@@ -498,6 -901,6 +901,10 @@@ static int resolve_single_call(cbm_pipe: cbm_pipeline_lsp_target_node(ctx->gbuf, ctx->project_name,lsp->callee_qn, allow_tail);if (target_node && source_node->id != target_node->id) {++ /* LSP textual fallbacks can also name data, as with static imports. */++ if (cbm_java_suppress_call_to_data_member(lang == CBM_LANG_JAVA, target_node->label)) {++ return 0;++ }cbm_resolution_t res = {0};/* Use the gbuf node's QN so downstream edge props show the canonical* project-qualified form even when fallback prefixed the project. */@@@ -680,16 -1213,23 +1217,29 @@@* Store.commit() call to a JS function named commit (or a Bash main* to a Python main). Drop that weak cross-language edge. */if (cbm_suppress_cross_language_suffix_match(lang, target_node->file_path, res.strategy)) {+ /* Refusing the binding leaves the callee unresolved, and an+ * unresolved route-registration callee is still a registration:+ * `Route::get('/x', ...)` beside a JS `get`, `app.get('/x', h)`+ * beside a Python `get`. Give it the same Route the #952+ * unresolved-callee fallback above mints, and nothing else. Dropping+ * the whole call lost every GET registration in a mixed-language repo+ * while POST (no `post` to collide with) survived. */+ if (cbm_service_pattern_route_method(call->callee_name) != NULL && call->first_string_arg &&+ call->first_string_arg[0] == '/') {+ handle_route_registration(ctx, call, source_node, module_qn, imp_keys, imp_vals,+ imp_count, route_mount, lang);+ return SKIP_ONE;+ }return 0;}+ /* A Java call never targets data — see cbm_java_suppress_call_to_data_member.+ * The language gate lives here, as with the guards above, and MUST match+ * pass_parallel.c exactly or the two resolvers diverge. */+ if (cbm_java_suppress_call_to_data_member(lang == CBM_LANG_JAVA, target_node->label)) {+ return 0;+ }emit_classified_edge(ctx, call, source_node, target_node, &res, module_qn, imp_keys, imp_vals,- imp_count, drop_plain_call);+ imp_count, drop_plain_call, route_mount, lang);return SKIP_ONE;}diff --cc src/pipeline/pass_parallel.cindex 380679c13,73ce742ad..23f4934ce--- a/src/pipeline/pass_parallel.c+++ b/src/pipeline/pass_parallel.c@@@ -3025,15 -3569,13 +3569,19 @@@ static void resolve_file_calls(resolve_if (target_node && source_node->id != target_node->id &&cbm_suppress_cross_language_suffix_match(lang, target_node->file_path, res.strategy)) {/* #725: same guard as pass_calls.c — do not emit a suffix_match- * CALLS edge across a language boundary. */+ * CALLS edge across a language boundary. A route registration+ * behind the refused binding still gets its Route. */+ emit_xlang_refused_route(ws->local_edge_buf, source_node, call, module_qn, rc->registry,+ rc->main_gbuf, imp_keys, imp_vals, imp_count, route_mount,+ lang);continue;}+ if (target_node && source_node->id != target_node->id &&+ cbm_java_suppress_call_to_data_member(lang == CBM_LANG_JAVA, target_node->label)) {+ /* Same guard as pass_calls.c — a Java call never targets a+ * Variable or a Field. */+ continue;+ }if (!target_node || source_node->id == target_node->id) {/* HTTP/ASYNC calls to an EXTERNAL client library (`requests.get(url)`)* resolve to an unindexed QN (target_node == NULL), but their edgediff --cc src/pipeline/pipeline.hindex 416c5b25a,ddc14e737..fca310004--- a/src/pipeline/pipeline.h+++ b/src/pipeline/pipeline.h@@@ -344,13 -455,42 +455,49 @@@ bool cbm_suppress_cross_language_ref(CB* unit-tested in test_registry.c. */bool cbm_go_suppress_bare_field_ref(bool is_go, bool is_member_access, const char *target_label);+ /* What to do with a call whose registry resolution landed on a Field node.+ * Pure; unit-tested in test_registry.c. */+ typedef enum {+ CBM_FIELD_CALL_KEEP = 0, /* not a Field target, or a language this rule leaves alone */+ CBM_FIELD_CALL_DROP, /* a Field can never be this call's target */+ CBM_FIELD_CALL_BY_OWNER, /* C/C++ member call: the object's type names the Field */+ } cbm_field_call_policy_t;+ cbm_field_call_policy_t cbm_call_onto_field_policy(CBMLanguage caller_lang, const char *callee_text,+ const char *target_label,+ const char *target_file_path);++ /* True for a C/C++ call spelled through an arrow (`p->open(fd)`). The+ * short-name registry splits a callee on `.` and `::` only, so such a call+ * comes back from it unresolved; the caller then asks the object's type for+ * the member, as for a dot call. Pure; unit-tested in test_registry.c. */+ bool cbm_c_arrow_member_call(CBMLanguage caller_lang, const char *callee_text);++ /* True when a reference is the member half of a C `a.b` / `a->b`. Such a+ * reference binds through the C LSP's field-owner rows (the type of `a`); with+ * no typed owner it binds only cbm_registry_unique_field_qn(). C only. Pure;+ * unit-tested in test_registry.c. */+ bool cbm_c_member_binds_by_owner(bool is_c, bool is_member_access);++ /* True when a file's member accesses follow the C member rule above: every C+ * file, and every `.h`. A `.h` is parsed as C++ because it may be either, and+ * `a.b` / `a->b` means the same in both: the type of `a` names `b`. Without it+ * the inline functions of a C header kept binding members by bare name. Other+ * C++ files are left to their own resolution. Pure; unit-tested in+ * test_registry.c. */+ bool cbm_c_member_rule_file(CBMLanguage lang, const char *rel_path);++ /* The QN of the Field `member_name` names when exactly one Field in the+ * registry carries that name (symbols of other labels are not candidates for+ * a member); NULL when none or several do. */+ const char *cbm_registry_unique_field_qn(const cbm_registry_t *r, const char *member_name);++/* A Java call expression never names data: `p.x()` is a method invocation+ * whatever `x` spells elsewhere in the project. Drops a CALLS bind whose+ * target is a Variable or Field. Java only — Kotlin properties and C function+ * pointers are callable names that are not methods. Pure; unit-tested in+ * test_registry.c. */+bool cbm_java_suppress_call_to_data_member(bool is_java, const char *target_label);+/* Get the label of a qualified name, or NULL if not found. */const char *cbm_registry_label_of(const cbm_registry_t *r, const char *qn);diff --cc src/pipeline/registry.cindex 2a9fb19fb,8da94b096..209691ea2--- a/src/pipeline/registry.c+++ b/src/pipeline/registry.c@@@ -811,30 -1057,72 +1057,96 @@@ bool cbm_go_suppress_bare_field_ref(booreturn strcmp(target_label, "Field") == 0;}+ cbm_field_call_policy_t cbm_call_onto_field_policy(CBMLanguage caller_lang, const char *callee_text,+ const char *target_label,+ const char *target_file_path) {+ /* The short-name registry holds Field nodes, so a call spelled like some+ * struct member can resolve onto that Field. Three shapes are decided here:+ * - a caller in another language: nothing but the spelling connects a+ * Bash `command` or a Python `sorted()` to a C struct member. The+ * unique_name exemption of the CALLS guard (#1572) is about functions;+ * for a Field the #1928 reference rule applies, with its JS/TS and+ * C/C++ family exemptions;+ * - a bare C call (`socket(...)`, a function-pointer parameter+ * `want(x)`): a bare C name is never a struct member;+ * - a C or C++ member call (`cb.close(ctx)`, `text.size()`): the type of+ * the object decides which struct's member is called, never the+ * member name alone. The C LSP publishes owners in both modes.+ * A bare C++ call keeps its resolution (a method body reaches its own+ * members without a selector), and so does every other language. */+ if (!target_label || strcmp(target_label, "Field") != 0) {+ return CBM_FIELD_CALL_KEEP;+ }+ if (cbm_suppress_cross_language_ref(caller_lang, target_file_path)) {+ return CBM_FIELD_CALL_DROP;+ }+ if (caller_lang != CBM_LANG_C && caller_lang != CBM_LANG_CPP) {+ return CBM_FIELD_CALL_KEEP;+ }+ if (callee_text && (strchr(callee_text, '.') || strstr(callee_text, "->"))) {+ return CBM_FIELD_CALL_BY_OWNER;+ }+ return caller_lang == CBM_LANG_C ? CBM_FIELD_CALL_DROP : CBM_FIELD_CALL_KEEP;+ }++ bool cbm_c_arrow_member_call(CBMLanguage caller_lang, const char *callee_text) {+ if (caller_lang != CBM_LANG_C && caller_lang != CBM_LANG_CPP) {+ return false;+ }+ return callee_text != NULL && strstr(callee_text, "->") != NULL;+ }++ bool cbm_c_member_rule_file(CBMLanguage lang, const char *rel_path) {+ if (lang == CBM_LANG_C) {+ return true;+ }+ if (lang != CBM_LANG_CPP || !rel_path) {+ return false;+ }+ size_t len = strlen(rel_path);+ return len > PAIR_LEN && strcmp(rel_path + len - PAIR_LEN, ".h") == 0;+ }++ bool cbm_c_member_binds_by_owner(bool is_c, bool is_member_access) {+ /* The member half of `a.b` / `a->b` is not a name in any C scope: only the+ * type of `a` gives `b` a meaning. Handing the bare `b` to the short-name+ * registry bound whichever Field (or function, or variable) was called+ * `b` -- on this repository 9,150 USAGE and 2,810 WRITES edges onto+ * Fields, 3,976 of the USAGE edges on a name several structs share. Such a+ * reference binds through the C LSP's field-owner rows; an object the LSP+ * could not type binds only a member name that is unique in the project+ * (cbm_registry_unique_field_qn), never one of several.+ *+ * C-gated like the Go rule above: a C++ or Objective-C method body+ * reaches its own members without a selector, and their member accesses+ * keep the existing resolution until their LSPs publish owners too. */+ return is_c && is_member_access;+ }++bool cbm_java_suppress_call_to_data_member(bool is_java, const char *target_label) {+ /* A Java call expression never names data. `p.x()` is a method invocation+ * whatever `x` spells elsewhere in the tree, so a CALLS edge into a+ * Variable or a Field is a spelling collision and not a call.+ *+ * The bind is reached when the type-aware resolver finds no method to+ * return: a record's accessors are implicit, so `record Point(double x,+ * double y, double z)` declares no `x()` for java_lookup_method to find,+ * and every `p.x()` falls through to the short-name registry — which+ * matches the first `x` anywhere in the project, typically an unrelated+ * class's private field. Measured on a 600-file Java tree (2026-09-22):+ * 278 of 2444 CALLS edges landed on fields that way, and the callers of+ * one four-field class absorbed every record read in the project.+ *+ * Java-gated, like the Go guard above, because the veto is only sound+ * where no callable name can be anything but a method: Kotlin properties+ * hold function values (`val f: () -> Unit; f()`) and C has function+ * pointers, so both legitimately call through data. */+ if (!is_java || !target_label) {+ return false;+ }+ return strcmp(target_label, "Variable") == 0 || strcmp(target_label, "Field") == 0;+}+/* ── Lifecycle ──────────────────────────────────────────────────── */cbm_registry_t *cbm_registry_new(void) {diff --cc tests/test_call_reference_contract.cindex d7aa27939,3a7b3acd1..67e30132a--- a/tests/test_call_reference_contract.c+++ b/tests/test_call_reference_contract.c@@@ -457,56 -423,6 +457,127 @@@ TEST(call_reference_go_ambiguous_promotPASS();}+TEST(call_java_record_accessor_binds_the_record) {+ /* A record's accessors are implicit, so `record Point(double x, ...)`+ * declares no `x()` in its source. Extraction emits them, and `other.x()`+ * binds to the record's own accessor.+ *+ * Two things must not happen instead. The call must not reach the+ * project-wide short-name registry and land on the first `x` in the tree —+ * here an unrelated class's private field. And the guard that refuses such+ * data binds must not swallow a real method that merely shares the+ * spelling: the builder's `x(int)`, declared beside its own `x` field,+ * keeps its edge. */+ static const RFile files[] = {+ {"Point.java", "package com.example;\n"+ "public record Point(double x, double y, double z) {\n"+ " public double first(Point other) {\n"+ " return Maths.abs(other.x()) + new Builder().x(5).made();\n"+ " }\n"+ "}\n"},+ {"Spring.java", "package com.example;\n"+ "public final class Spring {\n"+ " private double x;\n"+ " public void put(double v) { this.x = v; }\n"+ "}\n"},+ {"Builder.java", "package com.example;\n"+ "public final class Builder {\n"+ " private int x;\n"+ " public Builder x(int v) { this.x = v; return this; }\n"+ " public int made() { return x; }\n"+ "}\n"},+ {"Maths.java", "package com.example;\n"+ "public final class Maths {\n"+ " public static double abs(double v) { return v < 0 ? -v : v; }\n"+ "}\n"}};+ RProj project;+ cbm_store_t *store = rh_index_files(&project, files, 4);+ ASSERT_NOT_NULL(store);+ int fabricated_field = crc_edge_count(store, project.project, "CALLS", "first", "Field", "x");+ int fabricated_var = crc_edge_count(store, project.project, "CALLS", "first", "Variable", "x");+ int genuine = crc_edge_count(store, project.project, "CALLS", "first", "Method", "abs");+ int accessor = crc_edge_count_to_qn(store, project.project, "CALLS", "first", ".Point.x");+ int builder = crc_edge_count_to_qn(store, project.project, "CALLS", "first", ".Builder.x");+ rh_cleanup(&project, store);+ ASSERT_EQ(fabricated_field, 0);+ ASSERT_EQ(fabricated_var, 0);+ ASSERT_EQ(genuine, 1);+ ASSERT_EQ(accessor, 1);+ ASSERT_EQ(builder, 1);+ PASS();+}+++/* Static imports can name both an inherited method and a field. Thread's++ * activeCount() is external to this project, whereas Owner.activeCount is++ * local data; an unresolved import must not turn the field into a callee. */++static int crc_java_static_import_data_call_count(bool parallel) {++ RFile files[52] = {{"example/Owner.java", "package example;\n"++ "public class Owner extends Thread {\n"++ " public static int activeCount;\n"++ "}\n"},++ {"example/Caller.java", "package example;\n"++ "import static example.Owner.activeCount;\n"++ "class Caller {\n"++ " int caller() { return activeCount(); }\n"++ "}\n"}};++ char names[50][64];++ char sources[50][64];++ int count = parallel ? 52 : 2;++ for (int i = 2; i < count; i++) {++ snprintf(names[i - 2], sizeof(names[i - 2]), "example/Pad%d.java", i);++ snprintf(sources[i - 2], sizeof(sources[i - 2]), "package example; class Pad%d {}\n", i);++ files[i].name = names[i - 2];++ files[i].content = sources[i - 2];++ }++ RProj project;++ cbm_store_t *store = rh_index_files(&project, files, count);++ if (!store) {++ return -1;++ }++ int fields = crc_edge_count(store, project.project, "CALLS", "caller", "Field", "activeCount");++ int vars = crc_edge_count(store, project.project, "CALLS", "caller", "Variable", "activeCount");++ rh_cleanup(&project, store);++ return fields < 0 || vars < 0 ? -1 : fields + vars;++}++++TEST(call_java_static_import_does_not_call_field_sequential) {++ ASSERT_EQ(crc_java_static_import_data_call_count(false), 0);++ PASS();++}++++TEST(call_java_static_import_does_not_call_field_parallel) {++ ASSERT_EQ(crc_java_static_import_data_call_count(true), 0);++ PASS();++}++++TEST(call_java_record_varargs_accessor_has_array_return) {++ static const char *sources[] = {++ "record Values(String... xs) {}\n", "record Values(String[]... xs) {}\n",++ "record Values(int... xs) {}\n", "record Values(@Deprecated String... xs) {}\n",++ "record Values(String... xs) { public String[] xs() { return xs; } }\n"};++ static const char *return_types[] = {"String[]", "String[][]", "int[]", "String[]", "String[]"};++ for (int fixture = 0; fixture < 5; fixture++) {++ CBMFileResult *result =++ cbm_extract_file(sources[fixture], (int)strlen(sources[fixture]), CBM_LANG_JAVA,++ "repro", "Values.java", 0, NULL, NULL);++ ASSERT_NOT_NULL(result);++ int accessors = 0;++ bool array_return = false;++ for (int i = 0; i < result->defs.count; i++) {++ CBMDefinition *def = &result->defs.items[i];++ if (strcmp(def->name, "xs") == 0 && strcmp(def->label, "Method") == 0) {++ accessors++;++ array_return =++ def->return_type && strcmp(def->return_type, return_types[fixture]) == 0;++ }++ }++ cbm_free_result(result);++ ASSERT_EQ(accessors, 1);++ ASSERT_TRUE(array_return);++ }++ PASS();++}++SUITE(call_reference_contract) {RUN_TEST(call_reference_typescript_direct_argument_is_exact);RUN_TEST(call_reference_kotlin_alias_argument_is_exact);@@@ -523,5 -439,4 +594,8 @@@RUN_TEST(call_reference_python_later_decorated_method_rebinding_stays_usage);RUN_TEST(call_reference_go_bound_method_argument_is_exact);RUN_TEST(call_reference_go_ambiguous_promoted_method_stays_usage);+ RUN_TEST(call_java_record_accessor_binds_the_record);++ RUN_TEST(call_java_record_varargs_accessor_has_array_return);++ RUN_TEST(call_java_static_import_does_not_call_field_sequential);++ RUN_TEST(call_java_static_import_does_not_call_field_parallel);}diff --cc tests/test_registry.cindex 126400da6,391fd3b88..d7e062bfc--- a/tests/test_registry.c+++ b/tests/test_registry.c@@@ -987,27 -1259,162 +1259,183 @@@ TEST(go_bare_ref_never_binds_field)PASS();}+ TEST(c_bare_call_does_not_weigh_field_namesakes) {+ /* 2026-10-13 kernel audit: a struct member named like a header function+ * made the bare name two candidates, the answer a suffix_match, and the+ * #725 guard (.h is C++) refused it -- `put_page(page)` 345 -> 9 callers.+ * A bare C call never names a member, so its Field namesakes do not+ * compete: the function is the unique name it was in v0.11.0. */+ cbm_registry_t *r = cbm_registry_new();+ cbm_registry_add_lang(r, "put_page", "proj.include.linux.mm.put_page", "Function",+ CBM_LANG_CPP);+ cbm_registry_add_lang(r, "put_page",+ "proj.arch.arm64.include.asm.kvm_pgtable.kvm_pgtable_mm_ops.put_page",+ "Field", CBM_LANG_CPP);+ const char *mod = "proj.arch.arm64.kernel.elfcore";+ cbm_resolution_t res =+ cbm_registry_resolve_call_lang(r, "put_page", mod, NULL, NULL, 0, CBM_LANG_C);+ ASSERT_STR_EQ(res.qualified_name, "proj.include.linux.mm.put_page");+ ASSERT_STR_EQ(res.strategy, "unique_name");+ /* The reference resolver and C++ (which reaches its own members bare) still+ * weigh the member: two candidates. */+ res = cbm_registry_resolve_lang(r, "put_page", mod, NULL, NULL, 0, CBM_LANG_C);+ ASSERT_STR_EQ(res.strategy, "suffix_match");+ res = cbm_registry_resolve_call_lang(r, "put_page", mod, NULL, NULL, 0, CBM_LANG_CPP);+ ASSERT_STR_EQ(res.strategy, "suffix_match");+ /* A name only members carry is no bare C call target at all -- neither a+ * struct member nor a C++ method: redis's libc `read()` became the unique+ * name of a Qt adapter's `read` Method once only Fields were set aside. */+ cbm_registry_add_lang(r, "on_close", "proj.net.sock.sock_ops.on_close", "Field", CBM_LANG_C);+ res = cbm_registry_resolve_call_lang(r, "on_close", mod, NULL, NULL, 0, CBM_LANG_C);+ ASSERT_TRUE(res.qualified_name == NULL || res.qualified_name[0] == '\0');+ cbm_registry_add_lang(r, "read", "proj.deps.hiredis.adapters.qt.RedisQtAdapter.read", "Method",+ CBM_LANG_CPP);+ cbm_registry_add_lang(r, "read", "proj.src.connection.ConnectionType.read", "Field",+ CBM_LANG_C);+ res = cbm_registry_resolve_call_lang(r, "read", mod, NULL, NULL, 0, CBM_LANG_C);+ ASSERT_TRUE(res.qualified_name == NULL || res.qualified_name[0] == '\0');+ /* C++ still reaches the method by name. */+ res = cbm_registry_resolve_call_lang(r, "read", mod, NULL, NULL, 0, CBM_LANG_CPP);+ ASSERT_TRUE(res.qualified_name && res.qualified_name[0] != '\0');+ cbm_registry_free(r);+ PASS();+ }++ TEST(call_onto_field_follows_language_and_shape) {+ /* A call the registry resolved onto a Field node. */+ /* Another language: only the spelling connects them. */+ ASSERT_EQ(cbm_call_onto_field_policy(CBM_LANG_BASH, "command", "Field", "src/probe.h"),+ CBM_FIELD_CALL_DROP);+ ASSERT_EQ(cbm_call_onto_field_policy(CBM_LANG_PYTHON, "sorted", "Field", "src/pool.c"),+ CBM_FIELD_CALL_DROP);+ /* A bare C call is never a struct member. */+ ASSERT_EQ(cbm_call_onto_field_policy(CBM_LANG_C, "socket", "Field", "tests/t.c"),+ CBM_FIELD_CALL_DROP);+ /* A C member call is decided by its object's type, in a .c or a .h. */+ ASSERT_EQ(cbm_call_onto_field_policy(CBM_LANG_C, "cb.close", "Field", "src/cb.h"),+ CBM_FIELD_CALL_BY_OWNER);+ ASSERT_EQ(cbm_call_onto_field_policy(CBM_LANG_C, "w->svc->app.cancel", "Field", "src/a.c"),+ CBM_FIELD_CALL_BY_OWNER);+ /* C++ reaches its own members bare, so a bare call keeps its resolution;+ * a member call is typed like C's (`text.size()` is not some struct's+ * `size` member). */+ ASSERT_EQ(cbm_call_onto_field_policy(CBM_LANG_CPP, "handler", "Field", "src/a.h"),+ CBM_FIELD_CALL_KEEP);+ ASSERT_EQ(cbm_call_onto_field_policy(CBM_LANG_CPP, "text.size", "Field", "src/a.h"),+ CBM_FIELD_CALL_BY_OWNER);+ /* The same language as the Field keeps its resolution too. */+ ASSERT_EQ(cbm_call_onto_field_policy(CBM_LANG_GO, "s.fn", "Field", "pkg/s.go"),+ CBM_FIELD_CALL_KEEP);+ /* Not a Field target: not this rule's business. */+ ASSERT_EQ(cbm_call_onto_field_policy(CBM_LANG_BASH, "main", "Function", "src/main.c"),+ CBM_FIELD_CALL_KEEP);+ ASSERT_EQ(cbm_call_onto_field_policy(CBM_LANG_C, "socket", NULL, "tests/t.c"),+ CBM_FIELD_CALL_KEEP);+ PASS();+ }++ TEST(c_arrow_member_call_is_c_family_and_arrow_only) {+ /* The registry returns nothing for an arrow callee; these are the calls+ * the resolvers then hand to the object's type. */+ ASSERT_TRUE(cbm_c_arrow_member_call(CBM_LANG_C, "o->open"));+ ASSERT_TRUE(cbm_c_arrow_member_call(CBM_LANG_C, "d->ops->shut"));+ ASSERT_TRUE(cbm_c_arrow_member_call(CBM_LANG_CPP, "self->hook"));+ /* A dot call resolves through the registry and its Field policy. */+ ASSERT_FALSE(cbm_c_arrow_member_call(CBM_LANG_C, "cb.close"));+ ASSERT_FALSE(cbm_c_arrow_member_call(CBM_LANG_C, "socket"));+ ASSERT_FALSE(cbm_c_arrow_member_call(CBM_LANG_C, NULL));+ /* Perl and PHP spell method calls with an arrow too: not this rule. */+ ASSERT_FALSE(cbm_c_arrow_member_call(CBM_LANG_PERL, "$obj->method"));+ ASSERT_FALSE(cbm_c_arrow_member_call(CBM_LANG_PHP, "$this->save"));+ PASS();+ }++ TEST(unique_field_qn_needs_exactly_one_field_of_that_name) {+ /* What an untyped C member access may still bind: a name exactly one+ * Field carries. Two Fields would be a choice; a function or variable of+ * the same name is not a candidate for a member at all. */+ cbm_registry_t *r = cbm_registry_new();+ ASSERT_NOT_NULL(r);+ cbm_registry_add(r, "only_here", "proj.a.Alpha.only_here", "Field");+ cbm_registry_add(r, "count", "proj.a.Alpha.count", "Field");+ cbm_registry_add(r, "count", "proj.b.Beta.count", "Field");+ cbm_registry_add(r, "close", "proj.cb.Callbacks.close", "Field");+ cbm_registry_add(r, "close", "proj.io.close", "Function");+ cbm_registry_add(r, "lonely_fn", "proj.io.lonely_fn", "Function");++ const char *only = cbm_registry_unique_field_qn(r, "only_here");+ ASSERT_NOT_NULL(only);+ ASSERT_STR_EQ(only, "proj.a.Alpha.only_here");+ /* Two fields share the name: no pick. */+ ASSERT_NULL(cbm_registry_unique_field_qn(r, "count"));+ /* One field and one function share the name: the function is not a+ * candidate for a member, so the field is still the only one. */+ const char *member = cbm_registry_unique_field_qn(r, "close");+ ASSERT_NOT_NULL(member);+ ASSERT_STR_EQ(member, "proj.cb.Callbacks.close");+ /* Unique, but not a field. */+ ASSERT_NULL(cbm_registry_unique_field_qn(r, "lonely_fn"));+ /* Unknown name and degenerate input. */+ ASSERT_NULL(cbm_registry_unique_field_qn(r, "absent"));+ ASSERT_NULL(cbm_registry_unique_field_qn(r, NULL));+ ASSERT_NULL(cbm_registry_unique_field_qn(NULL, "count"));+ cbm_registry_free(r);+ PASS();+ }++ TEST(c_member_access_binds_by_owner_only) {+ /* The member half of a C `a.b` / `a->b` means nothing without the type of+ * `a`: it binds through the C LSP's field-owner rows and never through a+ * bare-name lookup. The selector shape arrives as is_member_access. */+ ASSERT_TRUE(cbm_c_member_binds_by_owner(true, true));+ /* A bare C identifier keeps the ordinary resolution. */+ ASSERT_FALSE(cbm_c_member_binds_by_owner(true, false));+ /* Other languages keep theirs: a C++ or Objective-C method body reaches its+ * own members without a selector, and Go has its own rule above. */+ ASSERT_FALSE(cbm_c_member_binds_by_owner(false, true));+ ASSERT_FALSE(cbm_c_member_binds_by_owner(false, false));+ PASS();+ }++ TEST(c_member_rule_covers_c_files_and_every_dot_h) {+ ASSERT_TRUE(cbm_c_member_rule_file(CBM_LANG_C, "src/a.c"));+ ASSERT_TRUE(cbm_c_member_rule_file(CBM_LANG_C, NULL));+ /* A header is classified C++ whatever it holds; its inline functions+ * access members like the .c files that include it. */+ ASSERT_TRUE(cbm_c_member_rule_file(CBM_LANG_CPP, "include/linux/list.h"));+ /* Other C++ files keep their own resolution. */+ ASSERT_FALSE(cbm_c_member_rule_file(CBM_LANG_CPP, "src/widget.cpp"));+ ASSERT_FALSE(cbm_c_member_rule_file(CBM_LANG_CPP, "src/widget.hpp"));+ ASSERT_FALSE(cbm_c_member_rule_file(CBM_LANG_CPP, "src/match.hh"));+ ASSERT_FALSE(cbm_c_member_rule_file(CBM_LANG_CPP, ".h"));+ ASSERT_FALSE(cbm_c_member_rule_file(CBM_LANG_CPP, NULL));+ /* No other language, whatever the file is called. */+ ASSERT_FALSE(cbm_c_member_rule_file(CBM_LANG_OBJC, "ui/View.h"));+ ASSERT_FALSE(cbm_c_member_rule_file(CBM_LANG_GO, "pkg/a.go"));+ PASS();+ }++TEST(java_call_never_binds_data_member) {+ /* A Java call expression never names data, so a CALLS bind that landed on+ * a Variable or a Field is a spelling collision. The shape that produces+ * it: a record's accessors are implicit, `p.x()` finds no declared `x()`,+ * and the short-name registry hands back the first `x` in the tree — an+ * unrelated class's private field. */+ ASSERT_TRUE(cbm_java_suppress_call_to_data_member(true, "Field"));+ ASSERT_TRUE(cbm_java_suppress_call_to_data_member(true, "Variable"));+ /* Everything callable is kept, including the constructor's Class target. */+ ASSERT_FALSE(cbm_java_suppress_call_to_data_member(true, "Method"));+ ASSERT_FALSE(cbm_java_suppress_call_to_data_member(true, "Function"));+ ASSERT_FALSE(cbm_java_suppress_call_to_data_member(true, "Class"));+ /* Other languages have callable data: a Kotlin property or a C function+ * pointer is a name that is not a method and is called all the same. */+ ASSERT_FALSE(cbm_java_suppress_call_to_data_member(false, "Field"));+ ASSERT_FALSE(cbm_java_suppress_call_to_data_member(false, "Variable"));+ /* Degenerate input → nothing to judge. */+ ASSERT_FALSE(cbm_java_suppress_call_to_data_member(true, NULL));+ PASS();+}+TEST(dynamic_suppress_drops_weak_method_matches) {/* #592/#606/#1276: a member call whose receiver the LSP could not type, that* landed via a WEAK short-name strategy, is generic-resolver noise → drop.@@@ -1261,11 -2260,22 +2281,23 @@@ SUITE(registry)RUN_TEST(perl_suppress_drops_weak_builtin_and_method_matches);RUN_TEST(perl_suppress_keeps_high_confidence_and_genuine_calls);RUN_TEST(cross_language_suffix_match_drops_py_vs_js);+ RUN_TEST(lang_resolution_compatible_families);+ RUN_TEST(name_guess_vetoed_across_languages);+ RUN_TEST(same_module_vetoed_across_languages);RUN_TEST(cross_language_config_caller_drops_unique_name_too);RUN_TEST(registry_tie_break_is_independent_of_registration_order);+ RUN_TEST(registry_tie_prefers_callable_over_property);+ RUN_TEST(registry_tie_ignores_nesting_depth);+ RUN_TEST(registry_tie_prefers_csharp_implementation_over_ref_stub);RUN_TEST(cross_language_ref_drops_go_vs_c);RUN_TEST(go_bare_ref_never_binds_field);+ RUN_TEST(call_onto_field_follows_language_and_shape);+ RUN_TEST(c_bare_call_does_not_weigh_field_namesakes);+ RUN_TEST(c_arrow_member_call_is_c_family_and_arrow_only);+ RUN_TEST(unique_field_qn_needs_exactly_one_field_of_that_name);+ RUN_TEST(c_member_access_binds_by_owner_only);+ RUN_TEST(c_member_rule_covers_c_files_and_every_dot_h);+ RUN_TEST(java_call_never_binds_data_member);RUN_TEST(dynamic_suppress_drops_weak_method_matches);RUN_TEST(dynamic_suppress_keeps_high_confidence_and_non_methods);RUN_TEST(python_builtin_member_table_matches_builtin_type_methods);