fix(extract): Class.lines always 0 for all languages#449
Open
isc-tdyar wants to merge 1 commit into
Open
Conversation
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>
Owner
|
Thanks for the contribution — CI is fully green here too. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.