fix(extract): Class.lines always 0 for all languages#449
Open
isc-tdyar wants to merge 1 commit into
Open
Conversation
Owner
|
Thanks for the contribution — CI is fully green here too. |
Owner
|
Thanks @isc-tdyar — this one reviewed clean and is ready to merge, but it now conflicts with |
Owner
|
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
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.