fix(extract): enclosing-func detection uses lang_spec function_node_types

Root cause of the systemic callable-sourcing gap (QUALITY_ANALYSIS gap #3; only
3.69% of real-repo CALLS were Function/Method-sourced): func_kinds_for_lang fell
back to func_kinds_generic for the ~130 languages without a curated entry, missing
their real function node types, so cbm_find_enclosing_func never found the parent
function and attributed in-body calls to the Module node.

Fix: in the default case, use the language spec's function_node_types (the single
source of truth extraction already uses) when present. Curated languages (Go/
Python/C/C++/Rust/Java/...) are unchanged — no regression to the green gate.
Flips the callable-sourcing + enclosing-parity reproductions for the drifted
languages (dart/perl/scss/nix/fortran/cobol/verilog/vhdl/...) toward green.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
This commit is contained in:
Martin Vogel
2026-06-26 22:08:02 +02:00
parent 75fac86b53
commit db7660aaf0
+16 -1
View File
@@ -692,9 +692,24 @@ static const char **func_kinds_for_lang(CBMLanguage lang) {
return func_kinds_magma;
case CBM_LANG_WOLFRAM:
return func_kinds_wolfram;
default:
default: {
/* Enclosing-function drift fix (QUALITY_ANALYSIS gap #3): languages
* without a curated func_kinds entry previously fell back to
* func_kinds_generic, which misses their real function node types
* (e.g. dart function_signature, perl subroutine_declaration_statement,
* scss mixin_statement, nix function_expression, fortran subroutine,
* cobol program_definition, verilog/vhdl, ...). The enclosing-function
* walk then never found the parent function and attributed every
* in-body call to the Module node. Use the language spec's
* function_node_types (the single source of truth that extraction
* already uses) when the curated switch has no entry. Curated languages
* above are unchanged. */
const CBMLangSpec *spec = cbm_lang_spec(lang);
if (spec && spec->function_node_types && spec->function_node_types[0])
return spec->function_node_types;
return func_kinds_generic;
}
}
}
TSNode cbm_find_enclosing_func(TSNode node, CBMLanguage lang) {