Resolve function name for scripting/niche languages (Lua, OCaml, SQL, Zig, VimScript, Julia).
| 362 | |
| 363 | // Resolve function name for scripting/niche languages (Lua, OCaml, SQL, Zig, VimScript, Julia). |
| 364 | static TSNode resolve_func_name_scripting(TSNode node, CBMLanguage lang, const char *kind) { |
| 365 | if (lang == CBM_LANG_LUA && strcmp(kind, "function_definition") == 0) { |
| 366 | return resolve_lua_func_name(node); |
| 367 | } |
| 368 | if (lang == CBM_LANG_OCAML && strcmp(kind, "value_definition") == 0) { |
| 369 | return resolve_ocaml_func_name(node); |
| 370 | } |
| 371 | if (lang == CBM_LANG_SQL && strcmp(kind, "create_function") == 0) { |
| 372 | return resolve_sql_func_name(node); |
| 373 | } |
| 374 | if (lang == CBM_LANG_ZIG && strcmp(kind, "test_declaration") == 0) { |
| 375 | return resolve_zig_test_name(node); |
| 376 | } |
| 377 | if (lang == CBM_LANG_VIMSCRIPT && strcmp(kind, "function_definition") == 0) { |
| 378 | return resolve_vimscript_func_name(node); |
| 379 | } |
| 380 | if (lang == CBM_LANG_JULIA && strcmp(kind, "function_definition") == 0) { |
| 381 | return resolve_julia_func_name(node); |
| 382 | } |
| 383 | /* Julia short-form `name(args) = body` parses as an `assignment` whose LHS is |
| 384 | * a call_expression (`name(args)`); the function name is that call's head |
| 385 | * identifier. A plain `x = 5` (non-call LHS) is not a function — resolve NULL |
| 386 | * so it is neither extracted as a def nor scoped. */ |
| 387 | if (lang == CBM_LANG_JULIA && strcmp(kind, "assignment") == 0) { |
| 388 | if (ts_node_named_child_count(node) > 0) { |
| 389 | TSNode lhs = ts_node_named_child(node, 0); |
| 390 | if (!ts_node_is_null(lhs) && strcmp(ts_node_type(lhs), "call_expression") == 0) { |
| 391 | return resolve_julia_func_name(lhs); |
| 392 | } |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | TSNode null_node = {0}; |
| 397 | return null_node; |
| 398 | } |
| 399 | |
| 400 | // Lean: resolve function name from declId field. |
| 401 | static TSNode resolve_lean_func_name(TSNode node, TSNode name) { |
no test coverage detected