fix(graph): extract Dart abstract members and operators#75
fix(graph): extract Dart abstract members and operators#75giancarloerra wants to merge 1 commit into
Conversation
extractFromDart skipped any class member parsing as `declaration > <signature>` with no function body, so abstract bodyless getters, setters, and methods were dropped. Operators were missed entirely (with or without a body): operator_signature was unhandled and operators are not named by an identifier. - declaration branch now also handles function/getter/setter/operator signatures (abstract members); fields are still skipped. - method_signature branch now handles operator_signature (operators with a body), named operator<token> (operator+, operator==, operator[]). - Surface unparseable files: a one-time warn (per-file debug) when a Dart file has ERROR nodes, which for the bundled grammar means Dart 3 class modifiers (sealed/base/interface/final/mixin class) or extension types it cannot parse; those declarations are skipped, siblings still extract. Additive and backward compatible: no existing symbol changes id or kind, no new dependency, no data migration; changed files are re-extracted and replaced per-file on the next index.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR updates Dart symbol extraction to detect parser ERROR nodes, emit a deduplicated warning, extract additional bodyless member signatures including operators, expand unit coverage for those cases, and document current Dart grammar limitations in the README. ChangesDart symbol extraction
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Summary
Follow-up to #71 (full Dart support), addressing #74.
extractFromDartwas missing two member shapes, both now fixed, and it now surfaces files the bundled grammar cannot parse instead of failing silently.The split here is important and was verified empirically against the grammar: the abstract members and operators are real extraction gaps we own and fix in this PR. The
sealed class/ Dart 3 class modifiers part of #74 is an upstream grammar limitation (@ast-grep/lang-dart@0.0.7, the latest published, predates Dart 3 and emits ERROR nodes), not something we can fix in the extraction layer, so this PR documents it and adds a signal rather than pretending to solve it.Changes
void foo();,int get x;, andset y(int v);parse asdeclaration > <signature>with nofunction_body. The olddeclarationbranch only handledconstructor_signatureand skipped everything else, so abstract getters/setters/methods (common in Dart interfaces and abstract classes) were dropped. The branch now also handlesfunction_signature/getter_signature/setter_signature/operator_signature. Fields (no signature child) are still skipped.operator_signaturewas unhandled in themethod_signaturebranch, and operators are not named by an identifier. A smalloperatorNamehelper derives the name from the token after theoperatorkeyword, so symbols areOwner.operator+,Owner.operator==,Owner.operator[].sealed/base/interface/final/mixin classorextension type), a one-timewarnis logged per process (per-file detail atdebug). The affected declaration is skipped; depending on parser recovery, following sibling classes may also be lost, but the rest of the file still extracts.The grammar node shapes used here (
declaration > getter_signature/operator_signature,operator_signature > operator + binary_operator) were derived from the actual@ast-grep/lang-dart@0.0.7parse output, not assumed.Type of change
Testing
npm run test:unit): 852/852, including 6 newnpm run test:integration) — if applicablenpx tsc --noEmit)New tests: abstract bodyless getters/setters/methods; operators with and without a body, named by token (
operator+,operator==,operator[]); a no-regression test asserting fields stay skipped and constructors/getters-with-body are unchanged; sibling-class recovery past an unparseablesealed class; and the warn-once dedup. The 30 existing Dart tests and the full suite stay green.Backward compatibility
Additive and grammar-independent within one language's extractor. Verified against the code paths: no existing symbol changes id or kind (a before/after diff on the regression sample is byte-identical except for the added abstract/operator symbols); no new dependency; no data migration. Changed Dart files are re-extracted and their chunks/symbols replaced per-file on the next index (
deleteFileChunksinindexer.ts, per-file payload replacement insymbol-graph-incremental.ts), so there is no mixed state. Resolution can only gain edges (calls to operators/abstract methods now resolve), never lose them.Out of scope
sealed classand the other Dart 3 class modifiers remain unparseable until@ast-grep/lang-dartships a build against a current grammar. This PR documents the limitation and warns on it; it does not add a source-preprocessing workaround.Related issues
Fixes #74
Summary by CodeRabbit
New Features
Documentation