MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / extract_elixir_func_def

Function extract_elixir_func_def

internal/cbm/extract_defs.c:4359–4392  ·  view source on GitHub ↗

Handle Elixir def/defp/defmacro — extract function definition.

Source from the content-addressed store, hash-verified

4357
4358// Handle Elixir def/defp/defmacro — extract function definition.
4359static 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.
4395static TSNode emit_elixir_module_class(CBMExtractCtx *ctx, TSNode cur) {

Callers 1

extract_elixir_callFunction · 0.85

Calls 4

elixir_call_argsFunction · 0.85
cbm_node_textFunction · 0.85
cbm_fqn_computeFunction · 0.85
cbm_defs_pushFunction · 0.85

Tested by

no test coverage detected