fix(extract): Class.lines always 0 for all languages#449
Conversation
|
Thanks for the contribution — CI is fully green here too. |
|
Thanks @isc-tdyar — this one reviewed clean and is ready to merge, but it now conflicts with |
|
Thanks @isc-tdyar — the one-line |
2bd71e5 to
378b475
Compare
extract_class_def() sets start_line and end_line from the tree-sitter node span, but left def.lines = 0 (zeroed by memset at function entry). The equivalent function push_method_def() correctly computes def.lines = end_line - start_line + 1 The same one-liner was simply missing from the class extraction path. This affects all languages — Python, TypeScript, Go, and any other language where Class nodes are extracted via extract_class_def(). Regression test: after indexing a project, at least one Class node must have c.lines > 0. Signed-off-by: Thomas Dyar <tdyar@intersystems.com>
378b475 to
36e127c
Compare
|
Thanks for catching this, @isc-tdyar — a clean root-cause fix. |
Class.lines always 0 for all languages
Discovered while trying to sort classes by size. Every class node had
lines = 0regardless of actual length.Root cause
In
extract_class_def(),start_lineandend_lineare correctly set from tree-sitter node positions, butdef.linesis never computed — it stays 0 from thememsetthat zeroes the struct. The equivalent computation exists and is correct inpush_method_def():Fix
Add the same one-liner to
extract_class_def()afterend_lineis set. Affects all languages — any tree-sitter grammar that produces class nodes goes through this path.Regression test
tool_qg_class_lines_nonzerointests/test_incremental.c— indexes a project in full mode and asserts that at least one class node haslines > 0via aquery_graphtool call. Before the fix this assertion always failed.