Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/cbm/extract_defs.c
Original file line number Diff line number Diff line change
Expand Up @@ -3267,6 +3267,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);
Expand Down
48 changes: 48 additions & 0 deletions tests/test_incremental.c
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,52 @@ TEST(tool_list_projects_basic) {
PASS();
}

TEST(tool_qg_defines_method_more_than_10) {
write_file_at("fastapi/big_class.py",
"class BigClass:\n"
" def m1(self): pass\n"
" def m2(self): pass\n"
" def m3(self): pass\n"
" def m4(self): pass\n"
" def m5(self): pass\n"
" def m6(self): pass\n"
" def m7(self): pass\n"
" def m8(self): pass\n"
" def m9(self): pass\n"
" def m10(self): pass\n"
" def m11(self): pass\n"
" def m12(self): pass\n"
" def m13(self): pass\n"
" def m14(self): pass\n"
" def m15(self): pass\n");
char *idx = index_repo();
ASSERT(idx != NULL);
free(idx);
double ms;
char *r = call_tool_timed("query_graph", &ms,
"{\"project\":\"%s\","
"\"query\":\"MATCH (c:Class)-[:DEFINES_METHOD]->(m:Method)"
" WHERE c.name = 'BigClass' RETURN count(m) AS n\"}",
g_project);
TOOL_OK(r, ms);
ASSERT(strstr(r, "\"15\"") != NULL || strstr(r, "\\\"15\\\"") != NULL);
free(r);
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, "{}");
Expand Down Expand Up @@ -3042,6 +3088,8 @@ SUITE(incremental) {
RUN_TEST(tool_qg_configures);
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);

Expand Down
Loading