Skip to content

Add Dart support to codebase indexing#941

Open
WebMad wants to merge 1 commit into
Zoo-Code-Org:mainfrom
WebMad:feat/940-dart-codebase-indexing
Open

Add Dart support to codebase indexing#941
WebMad wants to merge 1 commit into
Zoo-Code-Org:mainfrom
WebMad:feat/940-dart-codebase-indexing

Conversation

@WebMad

@WebMad WebMad commented Jul 18, 2026

Copy link
Copy Markdown

Related GitHub Issue

Closes: #940

Description

Adds Dart support to Tree-sitter-based codebase indexing.

  • Registers .dart as a supported source extension and loads tree-sitter-dart.wasm.
  • Adds a Dart definitions query adapted from tree-sitter-dart's canonical tags query.
  • Captures classes, methods, constructors, factory and const constructors, getters, setters, operators, mixins, extensions, extension types, enums, type aliases, and top-level functions.
  • Adds focused parser and definition-extraction coverage using representative Dart declarations.
  • Keeps generated Dart files indexable; projects can continue excluding generated output through .gitignore or .rooignore when desired.

Reviewers should pay particular attention to the query patterns for constructors and top-level accessors, which differ structurally from class method signatures in the Dart grammar.

Test Procedure

Automated tests:

cd src
npx vitest run services/tree-sitter/__tests__/languageParser.spec.ts services/tree-sitter/__tests__/parseSourceCodeDefinitions.dart.spec.ts

Expected result: 2 test files and 8 tests pass.

The repository pre-commit and pre-push hooks were also run successfully:

  • ESLint across all workspace packages.
  • TypeScript type-checking across all workspace packages.

Manual verification:

  1. Open a Dart or Flutter workspace containing .dart files.
  2. Rebuild the codebase index.
  3. Search for a Dart class, mixin, enum, extension, constructor, getter/setter, or top-level function.
  4. Confirm that the corresponding Dart definition is returned as indexed context.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

Not applicable — this change has no UI impact.

Documentation Updates

  • No documentation updates are required.
  • Yes, documentation updates are required. (Please describe what needs to be updated or link to a PR in the docs repository).

Additional Notes

No generated-file suffixes such as *.g.dart or *.freezed.dart are hard-coded into the exclusion logic. Existing .gitignore and .rooignore behavior remains the source of truth, preserving access to generated APIs when projects intentionally index them.

Get in Touch

GitHub: @WebMad

Summary by CodeRabbit

  • New Features

    • Added Dart file support for source-code definition parsing.
    • Dart classes, methods, types, mixins, extensions, enums, and top-level functions are now recognized.
  • Tests

    • Added coverage for Dart parser loading and definition extraction across common language constructs.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

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 Plus

Run ID: b6c246f6-2e05-43d4-8de2-acb363a67efc

📥 Commits

Reviewing files that changed from the base of the PR and between 5f582a5 and e63a286.

📒 Files selected for processing (7)
  • src/services/tree-sitter/__tests__/fixtures/sample-dart.ts
  • src/services/tree-sitter/__tests__/languageParser.spec.ts
  • src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.dart.spec.ts
  • src/services/tree-sitter/index.ts
  • src/services/tree-sitter/languageParser.ts
  • src/services/tree-sitter/queries/dart.ts
  • src/services/tree-sitter/queries/index.ts

📝 Walkthrough

Walkthrough

Dart is added to tree-sitter’s recognized extensions, parser loading, query exports, and definition extraction coverage. Tests and a Dart fixture verify parser initialization and declarations including classes, methods, mixins, enums, extensions, typedefs, and top-level functions.

Changes

Dart tree-sitter support

Layer / File(s) Summary
Dart query and parser registration
src/services/tree-sitter/queries/dart.ts, src/services/tree-sitter/queries/index.ts, src/services/tree-sitter/languageParser.ts, src/services/tree-sitter/index.ts
Adds Dart Tree-sitter capture patterns, exports the query, loads the Dart grammar and query, and recognizes .dart files.
Dart parsing fixtures and validation
src/services/tree-sitter/__tests__/fixtures/sample-dart.ts, src/services/tree-sitter/__tests__/languageParser.spec.ts, src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.dart.spec.ts
Adds representative Dart source and verifies parser loading and extracted Dart declarations.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: edelauna, taltas, jamesrobert20

Sequence Diagram(s)

sequenceDiagram
  participant SourceFile
  participant loadRequiredLanguageParsers
  participant DartWasm
  participant Query
  participant DefinitionParser
  SourceFile->>loadRequiredLanguageParsers: provide .dart extension
  loadRequiredLanguageParsers->>DartWasm: load Dart grammar
  loadRequiredLanguageParsers->>Query: construct query from dartQuery
  Query-->>loadRequiredLanguageParsers: return Dart query
  DefinitionParser->>Query: extract Dart definitions
  Query-->>DefinitionParser: return captured declarations
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding Dart support to codebase indexing.
Description check ✅ Passed The PR description follows the template and fills the required issue, description, test procedure, checklist, notes, and contact sections.
Linked Issues check ✅ Passed The changes satisfy #940 by indexing .dart files, adding Dart queries/parsers, covering common Dart constructs, and preserving existing ignore behavior.
Out of Scope Changes check ✅ Passed All changes are directly related to Dart indexing support and its tests, with no clear unrelated scope creep.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@codecov

codecov Bot commented Jul 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions github-actions Bot added the awaiting-review PR changes are ready and waiting for maintainer re-review label Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review PR changes are ready and waiting for maintainer re-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT] Add Dart support to codebase indexing

1 participant