Skip to content

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.

fix(cs-lsp): emit cs_inherited_method for inherited bare calls and resolve using-static targets

Martin Vogel3b2a291e99c1
diff --git a/internal/cbm/lsp/cs_lsp.c b/internal/cbm/lsp/cs_lsp.c
index 78d0bddbd..077ef499b 100644
--- a/internal/cbm/lsp/cs_lsp.c
+++ b/internal/cbm/lsp/cs_lsp.c
@@ -1516,11 +1516,19 @@ static void cs_resolve_invocation(CSLSPContext *ctx, TSNode call) {
if (!fname) return;
char *bare = cs_strip_generic_args(ctx->arena, fname);
- /* Try enclosing class member. */
+ /* Try enclosing class member. cs_lookup_method walks the base chain, so
+ * a bare call may resolve to an INHERITED method. Distinguish, exactly
+ * as the instance-call path does: a method actually declared on the
+ * enclosing class is cs_self_method; one found on a base is
+ * cs_inherited_method. */
if (ctx->enclosing_class_qn) {
const CBMRegisteredFunc *f = cs_lookup_method(ctx, ctx->enclosing_class_qn, bare);
if (f) {
- cs_emit_resolved(ctx, f->qualified_name, "cs_self_method", 0.95f);
+ bool own =
+ f->receiver_type && strcmp(f->receiver_type, ctx->enclosing_class_qn) == 0;
+ cs_emit_resolved(ctx, f->qualified_name,
+ own ? "cs_self_method" : "cs_inherited_method",
+ own ? 0.95f : 0.92f);
return;
}
}
@@ -1534,11 +1542,16 @@ static void cs_resolve_invocation(CSLSPContext *ctx, TSNode call) {
return;
}
}
- /* Try `using static` imports. */
+ /* Try `using static` imports. The directive target is the namespace-
+ * qualified name as written ("Demo.MathUtil"), but types register under
+ * the file-stem QN ("proj.Client.MathUtil"); resolve the target through
+ * the type-name resolver (its short-name fallback bridges the two)
+ * before the method lookup. */
for (int i = 0; i < ctx->using_count; i++) {
const CBMCSUsing *u = &ctx->usings[i];
if (u->kind != CBM_CS_USING_STATIC) continue;
- const CBMRegisteredFunc *f = cs_lookup_method(ctx, u->target_qn, bare);
+ const char *host = cs_resolve_type_name(ctx, u->target_qn);
+ const CBMRegisteredFunc *f = cs_lookup_method(ctx, host ? host : u->target_qn, bare);
if (f) {
cs_emit_resolved(ctx, f->qualified_name, "cs_using_static", 0.90f);
return;