fix: populate Dart class definitions' children with field declarations - #2569
Merged
Conversation
extractDartClassMembers's field-scanning loop looked for an identifier as a DIRECT child of the declaration node, but every real Dart field shape (final Foo x;, Foo x;, late Foo x;, Foo? x;, final Foo a, b;) nests it two levels deep (declaration -> initialized_identifier_list -> initialized_identifier -> identifier) -- Dart requires a var/final/const/late/type modifier on every field, so identifier is never a direct child. This left every Dart class definition's children array permanently empty. Fixes the WASM extractor's loop to walk the correct path, mirroring handleDartFieldDeclTypeMap's identical traversal (including its handling of comma-separated multi-field declarations). The Rust/native extractor had no field-children collection at all -- extract_dart_ class_methods only ever pushed method definitions -- so this adds a new extract_dart_field_children helper and threads a children accumulator through to the class's own Definition. No doc updates needed -- internal extractor bug fix, no language/feature/architecture surface change. docs check acknowledged. Closes #2475 Impact: 1 functions changed, 3 affected
Contributor
Greptile SummaryThe PR fixes Dart class metadata so field declarations appear as property children in both native and WASM extraction paths.
Confidence Score: 5/5The PR appears safe to merge, with the native and WASM implementations aligned for the field-declaration shapes covered by the change. The changed extractors consistently populate class property children from nested initialized identifiers, preserve method output, and retain absent children for classes without fields; no concrete blocking or non-blocking defect remains. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart LR
Source["Dart class source"] --> Engine{"Extraction engine"}
Engine --> Native["Native Rust extractor"]
Engine --> Wasm["WASM TypeScript extractor"]
Native --> List1["initialized_identifier_list"]
Wasm --> List2["initialized_identifier_list"]
List1 --> Fields1["property children"]
List2 --> Fields2["property children"]
Fields1 --> Class["Class Definition.children"]
Fields2 --> Class
Reviews (1): Last reviewed commit: "fix: populate Dart class definitions' ch..." | Re-trigger Greptile |
Contributor
Codegraph Impact Analysis1 functions changed → 3 callers affected across 1 files
|
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
extractDartClassMembers's field-scanning loop looked for anidentifieras a DIRECT child of thedeclarationnode, but every real Dart field-declaration shape (final Foo x;,Foo x;,late Foo x;,Foo? x;,final Foo a, b;) nests it two levels deep:declaration -> initialized_identifier_list -> initialized_identifier -> identifier. Dart requires every field to carry avar/final/const/late/type modifier, soidentifieris never a direct child ofdeclaration— the loop silently found nothing for any real field, leaving a Dart class definition'schildrenarray permanently empty (confirmed empirically in the issue).src/extractors/dart.ts) to walk the correct path, mirroringhandleDartFieldDeclTypeMap's identical traversal — including its handling of a comma-separated multi-field declaration (final Foo a, b;declares bothaandb).crates/codegraph-core/src/extractors/dart.rs) had no field-children collection mechanism at all —extract_dart_class_methodsonly ever pushed methodDefinitions, and the class's ownDefinitionwas always built withchildren: None. Added a newextract_dart_field_childrenhelper and threaded achildren: &mut Vec<Definition>accumulator through, using the existingopt_childrenhelper for the finalNone-when-empty behavior.Low severity, matching the issue's own framing — doesn't affect call resolution or the resolution-benchmark fixtures, only the
childrenlisting on Dart class definitions (e.g. forcodegraph show ClassName-style output).Test plan
dart.rs(class_field_childrenmodule) — final field, plain/late field, comma-separated multi-field, methods-alongside-fields, no-fields-means-no-childrentests/parsers/dart.test.ts(#2475describe block) — same coverage, WASM enginenpx tsc --noEmit -p .,npm run lint, fullnpm test(5472 passed)cargo fmt -- --check,cargo clippy --lib -- -D warnings,cargo test --lib(1113 passed)Closes #2475