Skip to content

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.

Merge branch main into fix/elixir-extraction-defects

Martin Vogel00649064fe16
diff --cc internal/cbm/extract_defs.c
index 9e83b1fe0,0b6e13da9..c1869b8f0
--- a/internal/cbm/extract_defs.c
+++ b/internal/cbm/extract_defs.c
@@@ -5663,7 -9192,23 +9327,28 @@@ static void extract_elixir_call(CBMExtr
if (strcmp(macro, "def") == 0 || strcmp(macro, "defp") == 0 ||
strcmp(macro, "defmacro") == 0) {
- extract_elixir_func_def(ctx, cur, macro);
+ extract_elixir_func_def(ctx, cur, macro, &def_scope);
+ } else if (strcmp(macro, "if") == 0 || strcmp(macro, "unless") == 0) {
+ /* A compile-time if/unless in a module body defines functions
+ * under a condition: its do and else branches hold variants of the
+ * same definitions (graph_buffer.c, "Definition variants"). The
- * grammar nests the else_block inside the do_block. */
++ * grammar nests the else_block inside the do_block.
++ * The clause fold composes with this: fold_elixir_clause only
++ * folds a clause into one written in the same block, and each
++ * branch is its own block, so the clauses of one branch fold into
++ * one definition while the branches stay separate definitions that
++ * the graph buffer merges as variants of one identity. */
+ TSNode branch = cbm_find_child_by_kind(cur, "do_block");
+ for (int pass = 0; pass < 2 && !ts_node_is_null(branch); pass++) {
+ uint32_t bc = ts_node_child_count(branch);
+ for (int bi = (int)bc - SKIP_CHAR; bi >= 0; bi--) {
+ TSNode bchild = ts_node_child(branch, (uint32_t)bi);
+ if (!ts_node_is_null(bchild) && strcmp(ts_node_type(bchild), "call") == 0) {
+ ts_nstack_push(&stack, bchild);
+ }
+ }
+ branch = cbm_find_child_by_kind(branch, "else_block");
+ }
} else if (strcmp(macro, "defmodule") == 0) {
TSNode do_block = emit_elixir_module_class(ctx, cur);
if (!ts_node_is_null(do_block)) {