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

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

Source from the content-addressed store, hash-verified

8775
8776// Handle Elixir def/defp/defmacro — extract function definition.
8777static void extract_elixir_func_def(CBMExtractCtx *ctx, TSNode node, const char *macro) {
8778 CBMArena *a = ctx->arena;
8779 TSNode args = elixir_call_args(node);
8780 if (ts_node_is_null(args)) {
8781 return;
8782 }
8783
8784 TSNode first_arg = ts_node_child(args, 0);
8785 if (ts_node_is_null(first_arg)) {
8786 return;
8787 }
8788
8789 const char *fk = ts_node_type(first_arg);
8790 char *name = NULL;
8791 if (strcmp(fk, "call") == 0 && ts_node_child_count(first_arg) > 0) {
8792 name = cbm_node_text(a, ts_node_child(first_arg, 0), ctx->source);
8793 } else if (strcmp(fk, "identifier") == 0) {
8794 name = cbm_node_text(a, first_arg, ctx->source);
8795 }
8796 if (!name || !name[0]) {
8797 return;
8798 }
8799
8800 CBMDefinition def;
8801 memset(&def, 0, sizeof(def));
8802 def.name = name;
8803 def.qualified_name = cbm_fqn_compute(a, ctx->project, ctx->rel_path, name);
8804 def.label = "Function";
8805 def.file_path = ctx->rel_path;
8806 def.start_line = ts_node_start_point(node).row + TS_LINE_OFFSET;
8807 def.end_line = ts_node_end_point(node).row + TS_LINE_OFFSET;
8808 def.is_exported = (strcmp(macro, "def") == 0 || strcmp(macro, "defmacro") == 0);
8809 cbm_defs_push(&ctx->result->defs, a, def);
8810}
8811
8812// Emit Class definition for an Elixir defmodule node. Returns do_block or null.
8813static 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