Resolve the parameter-list node across the grammars used by the generic * definition extractor. Newer tree-sitter-kotlin exposes * `function_value_parameters` as a direct child rather than a `parameters` * field. Keep the legacy and ordered signature extractors on the same node so * adding positional metadata does not replace or reinterpret `param_types`. */
| 5170 | * field. Keep the legacy and ordered signature extractors on the same node so |
| 5171 | * adding positional metadata does not replace or reinterpret `param_types`. */ |
| 5172 | static TSNode find_function_params(TSNode func_node, CBMLanguage lang) { |
| 5173 | TSNode params = ts_node_child_by_field_name(func_node, TS_FIELD("parameters")); |
| 5174 | // ObjectScript exposes the parameter list under a `parameter_list` field. |
| 5175 | if (ts_node_is_null(params) && |
| 5176 | (lang == CBM_LANG_OBJECTSCRIPT_UDL || lang == CBM_LANG_OBJECTSCRIPT_ROUTINE)) { |
| 5177 | params = ts_node_child_by_field_name(func_node, TS_FIELD("parameter_list")); |
| 5178 | } |
| 5179 | if (ts_node_is_null(params) && lang == CBM_LANG_OBJECTSCRIPT_ROUTINE) { |
| 5180 | params = cbm_find_child_by_kind(func_node, "parameter_list"); |
| 5181 | } |
| 5182 | if (ts_node_is_null(params) && lang == CBM_LANG_OBJECTSCRIPT_UDL) { |
| 5183 | TSNode method_definition = cbm_find_child_by_kind(func_node, "method_definition"); |
| 5184 | if (!ts_node_is_null(method_definition)) { |
| 5185 | params = cbm_find_child_by_kind(method_definition, "arguments"); |
| 5186 | } |
| 5187 | } |
| 5188 | if (ts_node_is_null(params) && lang == CBM_LANG_KOTLIN) { |
| 5189 | params = cbm_find_child_by_kind(func_node, "function_value_parameters"); |
| 5190 | } |
| 5191 | if (ts_node_is_null(params) && (lang == CBM_LANG_C || lang == CBM_LANG_CPP || |
| 5192 | lang == CBM_LANG_CUDA || lang == CBM_LANG_GLSL)) { |
| 5193 | params = find_c_params(func_node); |
| 5194 | } |
| 5195 | return params; |
| 5196 | } |
| 5197 | |
| 5198 | /* ── C-family declared return type ────────────────────────────────── |
| 5199 | * The C-family grammars split a declared return type three ways: the `type` |
no test coverage detected