Skip to content

fix(extract): Class.lines always 0 for all languages#449

Open
isc-tdyar wants to merge 1 commit into
DeusData:mainfrom
isc-tdyar:fix/class-lines-zero
Open

fix(extract): Class.lines always 0 for all languages#449
isc-tdyar wants to merge 1 commit into
DeusData:mainfrom
isc-tdyar:fix/class-lines-zero

Conversation

@isc-tdyar

Copy link
Copy Markdown

Class.lines always 0 for all languages

Discovered while trying to sort classes by size. Every class node had lines = 0 regardless of actual length.

Root cause

In extract_class_def(), start_line and end_line are correctly set from tree-sitter node positions, but def.lines is never computed — it stays 0 from the memset that zeroes the struct. The equivalent computation exists and is correct in push_method_def():

// push_method_def — correct
def.lines = (int)(def.end_line - def.start_line + TS_LINE_OFFSET);

// extract_class_def — missing this line entirely
// def.lines was always 0

Fix

Add the same one-liner to extract_class_def() after end_line is set. Affects all languages — any tree-sitter grammar that produces class nodes goes through this path.

Regression test

tool_qg_class_lines_nonzero in tests/test_incremental.c — indexes a project in full mode and asserts that at least one class node has lines > 0 via a query_graph tool call. Before the fix this assertion always failed.

extract_class_def set start_line and end_line from tree-sitter node
positions but left def.lines = 0 (zeroed by memset). push_method_def
correctly computes lines = end_line - start_line + 1 — the same
one-liner was simply missing from the class extraction path.

Affects all languages: any tool call or Cypher query returning Class
nodes with a lines property always received 0, making it impossible to
sort classes by size or filter large classes.

Regression test: tool_qg_class_lines_nonzero in test_incremental.c.

Signed-off-by: Thomas Dyar <tdyar@intersystems.com>
@DeusData

Copy link
Copy Markdown
Owner

Thanks for the contribution — CI is fully green here too. Class.lines always being 0 is exactly the kind of quiet quality bug worth fixing; will review when time allows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants