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.

fix(extract): Class node lines property always 0

Thomas Dyar36e127c11303
diff --git a/internal/cbm/extract_defs.c b/internal/cbm/extract_defs.c
index bfff34fb1..40814045f 100644
--- a/internal/cbm/extract_defs.c
+++ b/internal/cbm/extract_defs.c
@@ -3323,6 +3323,7 @@ static void extract_class_def(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec
def.file_path = ctx->rel_path;
def.start_line = ts_node_start_point(node).row + TS_LINE_OFFSET;
def.end_line = ts_node_end_point(node).row + TS_LINE_OFFSET;
+ def.lines = (int)(def.end_line - def.start_line + TS_LINE_OFFSET);
def.is_exported = cbm_is_exported(name, ctx->language);
def.base_classes = extract_base_classes(a, node, ctx->source, ctx->language);
def.decorators = extract_decorators(a, node, ctx->source, ctx->language, spec);
diff --git a/tests/test_incremental.c b/tests/test_incremental.c
index 82aa289c1..3673bd935 100644
--- a/tests/test_incremental.c
+++ b/tests/test_incremental.c
@@ -964,6 +964,19 @@ TEST(tool_qg_defines_method_more_than_10) {
PASS();
}
+TEST(tool_qg_class_lines_nonzero) {
+ double ms;
+ char *r =
+ call_tool_timed("query_graph", &ms,
+ "{\"project\":\"%s\","
+ "\"query\":\"MATCH (c:Class) WHERE c.lines > 0 RETURN count(c) AS n\"}",
+ g_project);
+ TOOL_OK(r, ms);
+ ASSERT(strstr(r, "\"0\"") == NULL);
+ free(r);
+ PASS();
+}
+
TEST(tool_list_projects_has_current) {
double ms;
char *r = call_tool_timed("list_projects", &ms, "{}");
@@ -3105,6 +3118,7 @@ SUITE(incremental) {
RUN_TEST(tool_qg_handles);
RUN_TEST(tool_qg_defines_method);
RUN_TEST(tool_qg_defines_method_more_than_10);
+ RUN_TEST(tool_qg_class_lines_nonzero);
RUN_TEST(tool_qg_no_limit);
RUN_TEST(tool_qg_empty_result);