Skip to content

Commit f473119

Browse files
committed
fix(cpp): module-qualify out-of-line method caller QN so the LSP rescue joins
For an out-of-line method definition `int Processor::run() {...}`, c_lsp built the resolved-call caller QN from c_build_qn("Processor::run") = "Processor.run" — the bare class-qualified name with NO module prefix. The def walk and the call-scope QN both qualify the same method as "<module>.Processor.run", so the exact-equality join in cbm_pipeline_find_lsp_resolution missed and the LSP resolution (the correct caller for a call inside the out-of-line body, which tree-sitter alone attributes to the module) was silently discarded — the edge fell through to the registry resolver with no lsp_ strategy (gap #5a). When the class scope of a qualified declarator is resolved HERE to the full module-qualified class QN (saved_class_qn != enclosing_class_qn) and the built func_qn carries a bare class prefix, rebuild it as <class QN>.<method short name> so the caller QN matches both other producers and the rescue joins. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent e1bf7cc commit f473119

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎internal/cbm/lsp/c_lsp.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4251,6 +4251,17 @@ static void c_process_function(CLSPContext *ctx, TSNode func_node) {
42514251
if (ctx->enclosing_class_qn && saved_class_qn == ctx->enclosing_class_qn &&
42524252
!strchr(func_qn, '.')) {
42534253
func_qn = cbm_arena_sprintf(ctx->arena, "%s.%s", ctx->enclosing_class_qn, func_qn);
4254+
} else if (ctx->enclosing_class_qn && saved_class_qn != ctx->enclosing_class_qn &&
4255+
strchr(func_qn, '.')) {
4256+
/* Out-of-line method `Class::method`: c_build_qn yields the bare
4257+
* "Class.method" (no module) — the class scope was resolved HERE to the
4258+
* full module-qualified class QN (saved_class_qn != enclosing_class_qn).
4259+
* Rebuild as <class QN>.<method short name> so the caller_qn matches the
4260+
* def walk and call-scope QN, which qualify out-of-line methods the same
4261+
* way. Without this the caller_qn stays "Class.method", the exact-equality
4262+
* lsp_resolve join misses, and the LSP rescue is discarded (gap #5a). */
4263+
const char *dot = strrchr(func_qn, '.');
4264+
func_qn = cbm_arena_sprintf(ctx->arena, "%s.%s", ctx->enclosing_class_qn, dot + 1);
42544265
} else if (!strchr(func_qn, '.')) {
42554266
/* A free function in a namespace is qualified by the namespace scope
42564267
* (current_namespace is module_qn.ns), matching the def QN the extractor

0 commit comments

Comments
 (0)