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): resolve Java constructor references via class node + reason-match
Martin Vogelc18e3dc304ca
diff --git a/internal/cbm/lsp/java_lsp.c b/internal/cbm/lsp/java_lsp.cindex 342297aac..b350dc049 100644--- a/internal/cbm/lsp/java_lsp.c+++ b/internal/cbm/lsp/java_lsp.c@@ -1779,8 +1779,8 @@ void java_lsp_process_file(JavaLSPContext *ctx, TSNode root) {/* ── Call-edge resolution ─────────────────────────────────────────── */-static void java_emit_resolved(JavaLSPContext *ctx, const char *callee_qn, const char *strategy,- float confidence) {+static void java_emit_resolved_orig(JavaLSPContext *ctx, const char *callee_qn, const char *orig,+ const char *strategy, float confidence) {if (!ctx->resolved_calls || !ctx->enclosing_method_qn || !callee_qn)return;CBMResolvedCall rc;@@ -1788,10 +1788,19 @@ static void java_emit_resolved(JavaLSPContext *ctx, const char *callee_qn, constrc.callee_qn = callee_qn;rc.strategy = strategy;rc.confidence = confidence;- rc.reason = NULL;+ // For a data-flow resolution (constructor reference `Lhs::new` resolved to+ // the Lhs class), `reason` carries the ORIGINAL textual callee (`new`) so the+ // pipeline join can match the textual call site even though the resolved+ // callee_qn's short name differs. NULL/unread for normal resolved calls.+ rc.reason = orig;cbm_resolvedcall_push(ctx->resolved_calls, ctx->arena, rc);}+static void java_emit_resolved(JavaLSPContext *ctx, const char *callee_qn, const char *strategy,+ float confidence) {+ java_emit_resolved_orig(ctx, callee_qn, NULL, strategy, confidence);+}+static void java_emit_unresolved(JavaLSPContext *ctx, const char *expr_text, const char *reason) {if (!ctx->resolved_calls || !ctx->enclosing_method_qn)return;@@ -2587,12 +2596,15 @@ static void resolve_method_reference(JavaLSPContext *ctx, TSNode mref,short_name = short_name ? short_name + 1 : type_qn;const CBMRegisteredFunc *cf =cbm_registry_lookup_method(ctx->registry, type_qn, short_name);- if (cf) {- java_emit_resolved(ctx, cf->qualified_name, "lsp_method_ref_ctor", 0.90f);- } else {- java_emit_resolved(ctx, cbm_arena_sprintf(ctx->arena, "%s.%s", type_qn, short_name),- "lsp_method_ref_ctor_synth", 0.80f);- }+ // A `ClassName::new` reference constructs ClassName: resolve to the+ // ClassName CLASS node (which the textual extractor stored), not the+ // synthetic constructor QN that has no graph node. orig=mname ("new")+ // lets the join match the textual `new` call site (the constructor+ // reference is extracted as a call to `new`). cf distinguishes an+ // indexed constructor (higher confidence) from a synthesized one.+ java_emit_resolved_orig(ctx, type_qn, mname,+ cf ? "lsp_method_ref_ctor" : "lsp_method_ref_ctor_synth",+ cf ? 0.90f : 0.80f);return;}diff --git a/src/pipeline/lsp_resolve.h b/src/pipeline/lsp_resolve.hindex 5a942a196..0e2790531 100644--- a/src/pipeline/lsp_resolve.h+++ b/src/pipeline/lsp_resolve.h@@ -112,7 +112,9 @@ static inline const CBMResolvedCall *cbm_pipeline_find_lsp_resolution(* is never misread as an unresolved-call diagnostic. */if (!(rc->reason && rc->strategy &&(strcmp(rc->strategy, "lsp_func_ptr") == 0 ||- strcmp(rc->strategy, "lsp_dll_resolve") == 0) &&+ strcmp(rc->strategy, "lsp_dll_resolve") == 0 ||+ strcmp(rc->strategy, "lsp_method_ref_ctor") == 0 ||+ strcmp(rc->strategy, "lsp_method_ref_ctor_synth") == 0) &&strcmp(cbm_lsp_bare_segment(rc->reason), call_short) == 0)) {continue;}