Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
fix(extraction): convert fixed-size stacks in extract_channels.c to growable TSNodeStack
jjoos4d8440692159
diff --git a/internal/cbm/extract_channels.c b/internal/cbm/extract_channels.cindex 5b9f421de..c12d4ebeb 100644--- a/internal/cbm/extract_channels.c+++ b/internal/cbm/extract_channels.c@@ -134,12 +134,12 @@ static void scan_string_consts_js(CBMExtractCtx *ctx, chan_const_table_t *tbl) {/* Python constant resolution: NAME = "value" (assignment node). */static void scan_string_consts_python(CBMExtractCtx *ctx, chan_const_table_t *tbl) {- TSNode stack[CHAN_STACK_CAP];- int top = 0;- stack[top++] = ctx->root;+ TSNodeStack stack;+ ts_nstack_init(&stack, ctx->arena, CHAN_STACK_CAP);+ ts_nstack_push(&stack, ctx->arena, ctx->root);- while (top > 0 && tbl->count < CHAN_CONST_CAP) {- TSNode node = stack[--top];+ while (stack.count > 0 && tbl->count < CHAN_CONST_CAP) {+ TSNode node = ts_nstack_pop(&stack);const char *kind = ts_node_type(node);if (strcmp(kind, "assignment") == 0) {@@ -162,8 +162,8 @@ static void scan_string_consts_python(CBMExtractCtx *ctx, chan_const_table_t *tb}uint32_t count = ts_node_child_count(node);- for (int i = (int)count - SKIP_ONE; i >= 0 && top < CHAN_STACK_CAP; i--) {- stack[top++] = ts_node_child(node, (uint32_t)i);+ for (int i = (int)count - SKIP_ONE; i >= 0; i--) {+ ts_nstack_push(&stack, ctx->arena, ts_node_child(node, (uint32_t)i));}}}@@ -548,12 +548,12 @@ static void extract_channels_python(CBMExtractCtx *ctx) {chan_const_table_t consts = {0};scan_string_consts_python(ctx, &consts);- TSNode stack[CHAN_STACK_CAP];- int top = 0;- stack[top++] = ctx->root;+ TSNodeStack stack;+ ts_nstack_init(&stack, ctx->arena, CHAN_STACK_CAP);+ ts_nstack_push(&stack, ctx->arena, ctx->root);- while (top > 0) {- TSNode node = stack[--top];+ while (stack.count > 0) {+ TSNode node = ts_nstack_pop(&stack);const char *kind = ts_node_type(node);if (strcmp(kind, "call") == 0) {py_process_call(ctx, node, &consts);@@ -561,8 +561,8 @@ static void extract_channels_python(CBMExtractCtx *ctx) {py_process_decorator(ctx, node, &consts);}uint32_t count = ts_node_child_count(node);- for (int i = (int)count - SKIP_ONE; i >= 0 && top < CHAN_STACK_CAP; i--) {- stack[top++] = ts_node_child(node, (uint32_t)i);+ for (int i = (int)count - SKIP_ONE; i >= 0; i--) {+ ts_nstack_push(&stack, ctx->arena, ts_node_child(node, (uint32_t)i));}}}@@ -626,18 +626,18 @@ static void go_process_call(CBMExtractCtx *ctx, TSNode call) {}static void extract_channels_go(CBMExtractCtx *ctx) {- TSNode stack[CHAN_STACK_CAP];- int top = 0;- stack[top++] = ctx->root;+ TSNodeStack stack;+ ts_nstack_init(&stack, ctx->arena, CHAN_STACK_CAP);+ ts_nstack_push(&stack, ctx->arena, ctx->root);- while (top > 0) {- TSNode node = stack[--top];+ while (stack.count > 0) {+ TSNode node = ts_nstack_pop(&stack);if (strcmp(ts_node_type(node), "call_expression") == 0) {go_process_call(ctx, node);}uint32_t count = ts_node_child_count(node);- for (int i = (int)count - SKIP_ONE; i >= 0 && top < CHAN_STACK_CAP; i--) {- stack[top++] = ts_node_child(node, (uint32_t)i);+ for (int i = (int)count - SKIP_ONE; i >= 0; i--) {+ ts_nstack_push(&stack, ctx->arena, ts_node_child(node, (uint32_t)i));}}}@@ -723,12 +723,12 @@ static void java_process_annotation(CBMExtractCtx *ctx, TSNode annotation) {}static void extract_channels_java(CBMExtractCtx *ctx) {- TSNode stack[CHAN_STACK_CAP];- int top = 0;- stack[top++] = ctx->root;+ TSNodeStack stack;+ ts_nstack_init(&stack, ctx->arena, CHAN_STACK_CAP);+ ts_nstack_push(&stack, ctx->arena, ctx->root);- while (top > 0) {- TSNode node = stack[--top];+ while (stack.count > 0) {+ TSNode node = ts_nstack_pop(&stack);const char *kind = ts_node_type(node);if (strcmp(kind, "method_invocation") == 0) {java_process_call(ctx, node);@@ -736,8 +736,8 @@ static void extract_channels_java(CBMExtractCtx *ctx) {java_process_annotation(ctx, node);}uint32_t count = ts_node_child_count(node);- for (int i = (int)count - SKIP_ONE; i >= 0 && top < CHAN_STACK_CAP; i--) {- stack[top++] = ts_node_child(node, (uint32_t)i);+ for (int i = (int)count - SKIP_ONE; i >= 0; i--) {+ ts_nstack_push(&stack, ctx->arena, ts_node_child(node, (uint32_t)i));}}}@@ -792,18 +792,18 @@ static void csharp_process_call(CBMExtractCtx *ctx, TSNode call) {}static void extract_channels_csharp(CBMExtractCtx *ctx) {- TSNode stack[CHAN_STACK_CAP];- int top = 0;- stack[top++] = ctx->root;+ TSNodeStack stack;+ ts_nstack_init(&stack, ctx->arena, CHAN_STACK_CAP);+ ts_nstack_push(&stack, ctx->arena, ctx->root);- while (top > 0) {- TSNode node = stack[--top];+ while (stack.count > 0) {+ TSNode node = ts_nstack_pop(&stack);if (strcmp(ts_node_type(node), "invocation_expression") == 0) {csharp_process_call(ctx, node);}uint32_t count = ts_node_child_count(node);- for (int i = (int)count - SKIP_ONE; i >= 0 && top < CHAN_STACK_CAP; i--) {- stack[top++] = ts_node_child(node, (uint32_t)i);+ for (int i = (int)count - SKIP_ONE; i >= 0; i--) {+ ts_nstack_push(&stack, ctx->arena, ts_node_child(node, (uint32_t)i));}}}@@ -855,18 +855,18 @@ static void ruby_process_call(CBMExtractCtx *ctx, TSNode call) {}static void extract_channels_ruby(CBMExtractCtx *ctx) {- TSNode stack[CHAN_STACK_CAP];- int top = 0;- stack[top++] = ctx->root;+ TSNodeStack stack;+ ts_nstack_init(&stack, ctx->arena, CHAN_STACK_CAP);+ ts_nstack_push(&stack, ctx->arena, ctx->root);- while (top > 0) {- TSNode node = stack[--top];+ while (stack.count > 0) {+ TSNode node = ts_nstack_pop(&stack);if (strcmp(ts_node_type(node), "call") == 0) {ruby_process_call(ctx, node);}uint32_t count = ts_node_child_count(node);- for (int i = (int)count - SKIP_ONE; i >= 0 && top < CHAN_STACK_CAP; i--) {- stack[top++] = ts_node_child(node, (uint32_t)i);+ for (int i = (int)count - SKIP_ONE; i >= 0; i--) {+ ts_nstack_push(&stack, ctx->arena, ts_node_child(node, (uint32_t)i));}}}@@ -957,12 +957,12 @@ static void elixir_process_function_def(CBMExtractCtx *ctx, TSNode func_def) {}static void extract_channels_elixir(CBMExtractCtx *ctx) {- TSNode stack[CHAN_STACK_CAP];- int top = 0;- stack[top++] = ctx->root;+ TSNodeStack stack;+ ts_nstack_init(&stack, ctx->arena, CHAN_STACK_CAP);+ ts_nstack_push(&stack, ctx->arena, ctx->root);- while (top > 0) {- TSNode node = stack[--top];+ while (stack.count > 0) {+ TSNode node = ts_nstack_pop(&stack);const char *kind = ts_node_type(node);if (strcmp(kind, "call") == 0) {elixir_process_call(ctx, node);@@ -970,8 +970,8 @@ static void extract_channels_elixir(CBMExtractCtx *ctx) {elixir_process_function_def(ctx, node);}uint32_t count = ts_node_child_count(node);- for (int i = (int)count - SKIP_ONE; i >= 0 && top < CHAN_STACK_CAP; i--) {- stack[top++] = ts_node_child(node, (uint32_t)i);+ for (int i = (int)count - SKIP_ONE; i >= 0; i--) {+ ts_nstack_push(&stack, ctx->arena, ts_node_child(node, (uint32_t)i));}}}@@ -1033,18 +1033,18 @@ static void rust_process_call(CBMExtractCtx *ctx, TSNode call) {}static void extract_channels_rust(CBMExtractCtx *ctx) {- TSNode stack[CHAN_STACK_CAP];- int top = 0;- stack[top++] = ctx->root;+ TSNodeStack stack;+ ts_nstack_init(&stack, ctx->arena, CHAN_STACK_CAP);+ ts_nstack_push(&stack, ctx->arena, ctx->root);- while (top > 0) {- TSNode node = stack[--top];+ while (stack.count > 0) {+ TSNode node = ts_nstack_pop(&stack);if (strcmp(ts_node_type(node), "call_expression") == 0) {rust_process_call(ctx, node);}uint32_t count = ts_node_child_count(node);- for (int i = (int)count - SKIP_ONE; i >= 0 && top < CHAN_STACK_CAP; i--) {- stack[top++] = ts_node_child(node, (uint32_t)i);+ for (int i = (int)count - SKIP_ONE; i >= 0; i--) {+ ts_nstack_push(&stack, ctx->arena, ts_node_child(node, (uint32_t)i));}}}