Skip to content

fix(graph): extract Dart abstract members and operators#75

Open
giancarloerra wants to merge 1 commit into
mainfrom
feat/dart-abstract-members-operators
Open

fix(graph): extract Dart abstract members and operators#75
giancarloerra wants to merge 1 commit into
mainfrom
feat/dart-abstract-members-operators

Conversation

@giancarloerra

@giancarloerra giancarloerra commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to #71 (full Dart support), addressing #74. extractFromDart was 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

  • Abstract (bodyless) members now extract. Members like void foo();, int get x;, and set y(int v); parse as declaration > <signature> with no function_body. The old declaration branch only handled constructor_signature and skipped everything else, so abstract getters/setters/methods (common in Dart interfaces and abstract classes) were dropped. The branch now also handles function_signature / getter_signature / setter_signature / operator_signature. Fields (no signature child) are still skipped.
  • Operators now extract, with and without a body. Operators were missed entirely: operator_signature was unhandled in the method_signature branch, and operators are not named by an identifier. A small operatorName helper derives the name from the token after the operator keyword, so symbols are Owner.operator+, Owner.operator==, Owner.operator[].
  • Unparseable files are no longer silent. When a Dart file contains ERROR nodes (which for this grammar means Dart 3 class modifiers sealed/base/interface/final/mixin class or extension type), a one-time warn is logged per process (per-file detail at debug). The affected declaration is skipped; depending on parser recovery, following sibling classes may also be lost, but the rest of the file still extracts.
  • Doc comments updated to name the full set of grammar-unsupported Dart 3 constructs; README Dart line updated with operators and the grammar-gap caveat.

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.7 parse output, not assumed.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Test coverage improvement

Testing

  • Unit tests pass (npm run test:unit): 852/852, including 6 new
  • Integration tests pass (npm run test:integration) — if applicable
  • TypeScript compiles cleanly (npx tsc --noEmit)
  • New tests added for new/changed functionality

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 unparseable sealed 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 (deleteFileChunks in indexer.ts, per-file payload replacement in symbol-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 class and the other Dart 3 class modifiers remain unparseable until @ast-grep/lang-dart ships 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

    • Dart symbol extraction now includes methods, operators, getters, and setters alongside constructors for more comprehensive indexing.
    • Enhanced error detection for unsupported Dart 3 syntax with clear, deduplicated warnings.
  • Documentation

    • Updated README explaining Dart language support capabilities and current limitations with the bundled grammar.

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.
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b0930f77-0862-4e5e-8d2d-113c33d2aca0

📥 Commits

Reviewing files that changed from the base of the PR and between b2f368b and 0ab502b.

📒 Files selected for processing (3)
  • README.md
  • src/services/graph-symbols.ts
  • tests/unit/graph-symbols.test.ts

📝 Walkthrough

Walkthrough

This 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.

Changes

Dart symbol extraction

Layer / File(s) Summary
Extraction and warning flow
src/services/graph-symbols.ts
Dart extraction now counts parse ERROR nodes, emits a one-time warning with per-file debug logging, resets that warning state, and extracts bodyless declaration members plus operator signatures with derived operator names.
Tests and documentation
tests/unit/graph-symbols.test.ts, README.md
Tests cover abstract/bodyless members, operator naming, regression cases, recovery around unsupported Dart 3 syntax, and warning deduplication; the README now describes the Dart indexing scope and current grammar limits.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

  • Issue 74 in giancarloerra/SocratiCode — The changes add the unsupported-Dart warning path and the extra Dart member extraction covered by that issue.

Possibly related PRs

  • giancarloerra/SocratiCode#73 — This builds on the earlier Dart extractor work by extending Dart member handling and parse-warning behavior in src/services/graph-symbols.ts.

Poem

🐇 I hopped through Dartwood, light and spry,
Found skipped symbols hiding shy.
A warning now taps once per glade,
While operators join the parade.
With tests as carrots, neat and bright,
The burrow’s map reads more just right.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the primary changes: fixing Dart abstract member extraction and operator support, which are the core implementation improvements in this PR.
Description check ✅ Passed The description comprehensively addresses the template structure with detailed summary, changes, type of change selection, testing confirmation, backward compatibility analysis, and related issues.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/dart-abstract-members-operators

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Dart symbol extraction fails for sealed class and class-level getters

1 participant