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

Function extract_elixir_call

internal/cbm/extract_defs.c:5042–5080  ·  view source on GitHub ↗

Process Elixir call nodes iteratively — handles defmodule/def/defp/defmacro without recursion between extract_elixir_call ↔ extract_elixir_module_def.

Source from the content-addressed store, hash-verified

5040// Process Elixir call nodes iteratively — handles defmodule/def/defp/defmacro
5041// without recursion between extract_elixir_call ↔ extract_elixir_module_def.
5042static void extract_elixir_call(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec) {
5043 (void)spec;
5044 TSNodeStack stack;
5045 ts_nstack_init(&stack, ctx->arena, CBM_SZ_64);
5046 ts_nstack_push(&stack, ctx->arena, node);
5047
5048 while (stack.count > 0) {
5049 TSNode cur = ts_nstack_pop(&stack);
5050 CBMArena *a = ctx->arena;
5051
5052 if (ts_node_child_count(cur) == 0) {
5053 continue;
5054 }
5055 TSNode callee = ts_node_child(cur, 0);
5056 if (ts_node_is_null(callee)) {
5057 continue;
5058 }
5059 char *macro = cbm_node_text(a, callee, ctx->source);
5060 if (!macro) {
5061 continue;
5062 }
5063
5064 if (strcmp(macro, "def") == 0 || strcmp(macro, "defp") == 0 ||
5065 strcmp(macro, "defmacro") == 0) {
5066 extract_elixir_func_def(ctx, cur, macro);
5067 } else if (strcmp(macro, "defmodule") == 0) {
5068 TSNode do_block = emit_elixir_module_class(ctx, cur);
5069 if (!ts_node_is_null(do_block)) {
5070 uint32_t dbc = ts_node_child_count(do_block);
5071 for (int di = (int)dbc - SKIP_CHAR; di >= 0; di--) {
5072 TSNode dchild = ts_node_child(do_block, (uint32_t)di);
5073 if (!ts_node_is_null(dchild) && strcmp(ts_node_type(dchild), "call") == 0) {
5074 ts_nstack_push(&stack, ctx->arena, dchild);
5075 }
5076 }
5077 }
5078 }
5079 }
5080}
5081
5082// --- Variable extraction ---
5083

Callers 1

walk_defsFunction · 0.85

Calls 6

ts_nstack_initFunction · 0.85
ts_nstack_pushFunction · 0.85
ts_nstack_popFunction · 0.85
cbm_node_textFunction · 0.85
extract_elixir_func_defFunction · 0.85
emit_elixir_module_classFunction · 0.85

Tested by

no test coverage detected