Handle Elixir def/defp/defmacro — extract function definition.
| 4357 | |
| 4358 | // Handle Elixir def/defp/defmacro — extract function definition. |
| 4359 | static void extract_elixir_func_def(CBMExtractCtx *ctx, TSNode node, const char *macro) { |
| 4360 | CBMArena *a = ctx->arena; |
| 4361 | TSNode args = elixir_call_args(node); |
| 4362 | if (ts_node_is_null(args)) { |
| 4363 | return; |
| 4364 | } |
| 4365 | |
| 4366 | TSNode first_arg = ts_node_child(args, 0); |
| 4367 | if (ts_node_is_null(first_arg)) { |
| 4368 | return; |
| 4369 | } |
| 4370 | |
| 4371 | const char *fk = ts_node_type(first_arg); |
| 4372 | char *name = NULL; |
| 4373 | if (strcmp(fk, "call") == 0 && ts_node_child_count(first_arg) > 0) { |
| 4374 | name = cbm_node_text(a, ts_node_child(first_arg, 0), ctx->source); |
| 4375 | } else if (strcmp(fk, "identifier") == 0) { |
| 4376 | name = cbm_node_text(a, first_arg, ctx->source); |
| 4377 | } |
| 4378 | if (!name || !name[0]) { |
| 4379 | return; |
| 4380 | } |
| 4381 | |
| 4382 | CBMDefinition def; |
| 4383 | memset(&def, 0, sizeof(def)); |
| 4384 | def.name = name; |
| 4385 | def.qualified_name = cbm_fqn_compute(a, ctx->project, ctx->rel_path, name); |
| 4386 | def.label = "Function"; |
| 4387 | def.file_path = ctx->rel_path; |
| 4388 | def.start_line = ts_node_start_point(node).row + TS_LINE_OFFSET; |
| 4389 | def.end_line = ts_node_end_point(node).row + TS_LINE_OFFSET; |
| 4390 | def.is_exported = (strcmp(macro, "def") == 0 || strcmp(macro, "defmacro") == 0); |
| 4391 | cbm_defs_push(&ctx->result->defs, a, def); |
| 4392 | } |
| 4393 | |
| 4394 | // Emit Class definition for an Elixir defmodule node. Returns do_block or null. |
| 4395 | static TSNode emit_elixir_module_class(CBMExtractCtx *ctx, TSNode cur) { |
no test coverage detected