feat(core): add Dart language support (#317)#345
feat(core): add Dart language support (#317)#345pandacooming wants to merge 2 commits intozilliztech:masterfrom
Conversation
|
Thanks for taking this on. We merged #343 first to cover the immediate issue where .dart files were skipped by default. For this PR, the AST-based direction could still be useful, but I think it needs a follow-up revision before it is safe to merge:
Existing parsers like tree-sitter-javascript, tree-sitter-python, tree-sitter-java, and tree-sitter-scala require successfully in the same environment, so this looks specific to the new dependency or its native build setup.
After those are addressed, this can be reconsidered as an AST-level improvement on top of the basic Dart indexing support. |
79fad29 to
f7ce1a6
Compare
|
@zc277584121 Thanks for the review. All three points have been addressed in the latest push:
Branch has been rebased on current Note: the |
|
Thanks for the follow-up revision. I agree that AST-level Dart support could still be useful on top of the basic This branch is now quite far behind the current Could you please rebase on the latest
After that, this should be much easier to review again. |
f7ce1a6 to
968cce6
Compare
5ed6c6c to
64f7391
Compare
|
Thanks for the detailed follow-up. All four points have been addressed in the latest push (
All 14 tests pass (8 new Dart tests + 6 existing). Branch is cleanly rebased on latest upstream/master (d2ef81c). One additional note for context: The package ships only the C++ source (no prebuilt .node binary, no node-gyp-build for auto-compilation). This means the native binding will not load in most environments — the graceful fallback to LangChain character-based splitter kicks in instead. This is a limitation of the upstream package itself, not this PR. True AST-level Dart splitting will require either a tree-sitter-dart release with prebuilt binaries or a platform-specific build step. Ready for re-review. |
|
Thanks for the latest revision. The scope is much cleaner now, and the fallback direction makes sense. I tested this branch locally with:
The tests, typecheck, and build pass. However, in this environment Because of that, the new Dart tests currently validate the fallback path rather than confirming AST-based Dart splitting is actually active. Before merging, could you please make one more adjustment so the dependency failure is fully isolated to Dart usage?
With those changes, this would be much safer to merge as an AST-level improvement on top of the basic |
- Lazy-load tree-sitter-dart only when Dart split is requested, not at module import time. This isolates the dependency failure to Dart users and avoids console warnings for non-Dart users. - If the native binding is unavailable, emit exactly one warning and fall back to LangChain character-based splitter gracefully. - Verified by tests: non-Dart split triggers zero dart warnings; Dart split triggers exactly one. - Export SPLITTABLE_NODE_TYPES so the 6 Dart node types can be verified by unit tests (class_definition, mixin_declaration, extension_declaration, local_function_declaration, method_signature, constructor_signature). Reviewed against reviewer requirements (2026-04-29): 1. keep all existing tests/scripts ✓ 2. avoid unrelated README changes ✓ 3. avoid broad pnpm-workspace.yaml changes ✓ 4. keep fallback + dart split verification ✓ 5. [new] lazy-load only on Dart usage ✓ 6. [new] no warning on module import ✓
64f7391 to
30cf5e8
Compare
…rove dart-split-verify - Verify no dart warning when splitting non-Dart languages (lazy-load enforced by test) - Document the expected console output when native binding IS available vs unavailable - Improve dart-split-verify.ts: add AST/fallback path header, structural checks, clear success output for both paths
|
Thanks for the thorough review. All three points are addressed in the latest push ( 1. Lazy-load — no module-load dart require 2. Warning only when dart is split AND binding unavailable 3. Verification path for AST-based Dart splitting AST path (binding available — no warning, AST log shown): Fallback path (binding unavailable — warning, then graceful fallback): The script always exits 0 and proves Dart code is being processed (class/mixin/extension/function structural elements verified in output chunks). Test results:
PR state: 5 files, +387/-6, cleanly based on upstream master. Ready for re-review. |
Summary
Add Dart language support to the Claude Context code indexing engine, addressing feature request #317.
Changes
tree-sitter-dart@^1.0.0dependency.darttodartextension mapping ingetLanguageFromExtension()tree-sitter-dartparserfunction_declaration,method_declaration,class_declaration,constructor_declaration,mixin_declaration,extension_declaration)dartingetLanguageConfig()langMapdarttoisLanguageSupported()static methodTesting
pnpm run typecheckinpackages/core: passespnpm run buildinpackages/core: passesNotes
Dart support uses the same AST-based splitting approach as other languages (TypeScript, Scala). The
tree-sitter-dartparser is available at v1.0.0.Fixes #317