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`. */
| 3403 | * field. Keep the legacy and ordered signature extractors on the same node so |
| 3404 | * adding positional metadata does not replace or reinterpret `param_types`. */ |
| 3405 | static TSNode find_function_params(TSNode func_node, CBMLanguage lang) { |
| 3406 | TSNode params = ts_node_child_by_field_name(func_node, TS_FIELD("parameters")); |
| 3407 | // ObjectScript exposes the parameter list under a `parameter_list` field. |
| 3408 | if (ts_node_is_null(params) && |
| 3409 | (lang == CBM_LANG_OBJECTSCRIPT_UDL || lang == CBM_LANG_OBJECTSCRIPT_ROUTINE)) { |
| 3410 | params = ts_node_child_by_field_name(func_node, TS_FIELD("parameter_list")); |
| 3411 | } |
| 3412 | if (ts_node_is_null(params) && lang == CBM_LANG_OBJECTSCRIPT_ROUTINE) { |
| 3413 | params = cbm_find_child_by_kind(func_node, "parameter_list"); |
| 3414 | } |
| 3415 | if (ts_node_is_null(params) && lang == CBM_LANG_OBJECTSCRIPT_UDL) { |
| 3416 | TSNode method_definition = cbm_find_child_by_kind(func_node, "method_definition"); |
| 3417 | if (!ts_node_is_null(method_definition)) { |
| 3418 | params = cbm_find_child_by_kind(method_definition, "arguments"); |
| 3419 | } |
| 3420 | } |
| 3421 | if (ts_node_is_null(params) && lang == CBM_LANG_KOTLIN) { |
| 3422 | params = cbm_find_child_by_kind(func_node, "function_value_parameters"); |
| 3423 | } |
| 3424 | if (ts_node_is_null(params) && (lang == CBM_LANG_C || lang == CBM_LANG_CPP || |
| 3425 | lang == CBM_LANG_CUDA || lang == CBM_LANG_GLSL)) { |
| 3426 | params = find_c_params(func_node); |
| 3427 | } |
| 3428 | return params; |
| 3429 | } |
| 3430 | |
| 3431 | // C++: resolve trailing return type (auto f() -> Type) on a declarator node. |
| 3432 | // Updates def->return_type and def->return_types if trailing type found. |
no test coverage detected