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:4976–5009  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

4974
4975// Handle Elixir def/defp/defmacro — extract function definition.
4976static void extract_elixir_func_def(CBMExtractCtx *ctx, TSNode node, const char *macro) {
4977 CBMArena *a = ctx->arena;
4978 TSNode args = elixir_call_args(node);
4979 if (ts_node_is_null(args)) {
4980 return;
4981 }
4982
4983 TSNode first_arg = ts_node_child(args, 0);
4984 if (ts_node_is_null(first_arg)) {
4985 return;
4986 }
4987
4988 const char *fk = ts_node_type(first_arg);
4989 char *name = NULL;
4990 if (strcmp(fk, "call") == 0 && ts_node_child_count(first_arg) > 0) {
4991 name = cbm_node_text(a, ts_node_child(first_arg, 0), ctx->source);
4992 } else if (strcmp(fk, "identifier") == 0) {
4993 name = cbm_node_text(a, first_arg, ctx->source);
4994 }
4995 if (!name || !name[0]) {
4996 return;
4997 }
4998
4999 CBMDefinition def;
5000 memset(&def, 0, sizeof(def));
5001 def.name = name;
5002 def.qualified_name = cbm_fqn_compute(a, ctx->project, ctx->rel_path, name);
5003 def.label = "Function";
5004 def.file_path = ctx->rel_path;
5005 def.start_line = ts_node_start_point(node).row + TS_LINE_OFFSET;
5006 def.end_line = ts_node_end_point(node).row + TS_LINE_OFFSET;
5007 def.is_exported = (strcmp(macro, "def") == 0 || strcmp(macro, "defmacro") == 0);
5008 cbm_defs_push(&ctx->result->defs, a, def);
5009}
5010
5011// Emit Class definition for an Elixir defmodule node. Returns do_block or null.
5012static 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