feat: add Dart language support#204
Conversation
|
@mrwogu is attempting to deploy a commit to the NexusCore Team on Vercel. A member of the Team first needs to authorize it. |
2977da9 to
73e92fe
Compare
xkonjin
left a comment
There was a problem hiding this comment.
Quick review pass:
- Main risk area here is input validation, path handling, and malformed payload behavior.
- Good to see test coverage move with the code; I’d still make sure it exercises the unhappy path around input validation, path handling, and malformed payload behavior rather than only the happy path.
- Before merge, I’d smoke-test the behavior touched by supported-languages.ts, framework-detection.ts, parsing-processor.ts (+28 more) with malformed input / retry / rollback cases, since that’s where this class of change usually breaks.
reversTeam
left a comment
There was a problem hiding this comment.
Thorough and well-structured addition of Dart/Flutter language support. A few observations:
Strengths:
- Comprehensive tree-sitter queries covering classes, mixins, extensions, enums, type aliases, constructors (including factory), getters/setters, and heritage relationships (extends, implements, with).
- Dart import resolution is solid — correctly handles
dart:SDK imports (skip),package:imports (resolve tolib/), and relative imports (fall through to standard resolution). - Good use of
optionalDependenciesfortree-sitter-dart, consistent with how Swift is handled. - The test fixture (
simple.dart) is well-designed and covers most Dart constructs. Integration tests cover definitions, imports, and heritage extraction. - Framework detection for Flutter is comprehensive (main, screens, BLoC/cubit, services, widgets) with sensible multiplier values.
- Visibility logic (
_prefix = private) is correct for Dart.
Minor notes:
- The import resolution in
processImportsandprocessImportsFromExtractedhas near-identical Dart handling blocks (~25 lines each). Consider extracting a shared helper to reduce duplication, though this is a nit and can be done as a follow-up. - The vendored
tree-sitter-dartadds a lot of generated C code. If this grammar is published on npm, it might be worth switching to a versioned npm dependency in the future (liketree-sitter-swift), but vendoring is a reasonable approach for now given ABI compatibility concerns. - Missing newline at end of
supported-languages.tsandtree-sitter-queries.ts— trivial but worth fixing.
LGTM. Nice contribution!
|
Thanks for the reviews! Rebased onto latest Addressed the minor feedback:
Re the import resolution duplication ( All tests passing locally ( |
73e92fe to
91e19d7
Compare
|
Duplicate of #83 |
91e19d7 to
fcbd34c
Compare
|
Rebased onto latest Changes from the rebase:
All tree-sitter queries, vendor bindings, test fixtures, and web package changes are unchanged from the original PR. |
|
@claude ultra-think while identifying Dart-language gaps. Perform this analysis on this pull request and verify those findings. Act as a senior compiler font-end engineer and expert in static analysis tools and review this change from that perspective and review the architectural fit. Also check out previous comments and reason with their requests. |
|
Claude finished @magyargergo's task in 5m 41s —— View job Deep Dart Language Support ReviewTasks:
Review: Dart Language Support (feat: add Dart language support)Acting as a senior compiler front-end engineer and static analysis tooling expert. I've read all 17 source files introduced or modified by this PR. Architecture and Overall FitThe rebase-to-LanguageProvider architecture is well-executed. 🔴 Critical Issues1. Flutter framework detection completely absent from the CLI (
None of this landed in the CLI package. A Flutter project analyzed by the CLI will get no entry-point boost on any file. The web and CLI packages now behave differently for the same Dart input. Fix this → 2. Flutter AST patterns wired in neither package Both 'flutter': ['StatelessWidget', 'StatefulWidget', 'BuildContext', 'Widget build',
'ChangeNotifier', 'GetxController', 'Cubit<', 'Bloc<'],…but they are never wired to 🟠 High Severity Issues3.
const funcName = value.type === 'identifier' ? value : null;
4. Entry-point name patterns empty for Dart
[SupportedLanguages.Dart]: [],Flutter lifecycle methods are never scored as entry points. Missing patterns: /^build$/, // Widget.build — the fundamental Flutter render entry point
/^initState$/, // State lifecycle
/^dispose$/, // State lifecycle teardown
/^runApp$/, // App entry
/^onEvent$/, // BLoC event handler (Bloc library)
/^on[A-Z]/, // BLoC typed event handler pattern (already in UNIVERSAL but worth confirming)
/^mapEventToState$/, // legacy BLoCWithout these, 5. Dart/Flutter built-ins absent from noise filter
🟡 Medium Severity Issues6. Call extraction covers only
Both call queries anchor on
This is a shared limitation with other languages in this codebase, but the impact is disproportionately large for Dart/Flutter because widget 7. Call queries may produce phantom captures (expression_statement
(identifier) @call.name
.
(selector (argument_part))) @callThe 8.
(mixin_declaration
(identifier) @name) @definition.traitEvery other query uses 🟢 Low Severity / Nitpicks9. Extension types (Dart 3.x) not covered Dart 3.0 introduced extension types ( 10.
11. Test coverage gaps The 3 integration tests cover the happy path well, but these are missing:
12. Package import resolver doesn't scope by package name
const relPath = stripped.slice(slashIdx + 1); // strips package name entirely
const candidates = [`lib/${relPath}`, relPath];
13. Duplicate PR concern @magyargergo flagged this as a duplicate of #83. If #83 was closed/merged, verify there are no conflicting implementations or test regressions. If both PRs define Dart support, the latest one should win — but the git history should be clean. Summary Table
The foundation is solid. The import resolver, export checker, grammar vendoring, and provider registration are all done correctly. The CLI/web divergence on framework detection and the wired-but-inactive AST patterns are the two items that should be resolved before merge. |
|
@claude do we need to include the tree-sitter-dart native code just to support ABI 14? Is there any other way to go about it? I don't really want to the 3rd-party code here. research about alternatives. |
|
Addressed all critical and high-severity findings from the review: Critical:
High:
Medium:
Items intentionally deferred:
|
|
Claude finished @magyargergo's task in 2m 14s —— View job Tasks:
Why the vendor code existsThe problem is an ABI mismatch. Alternatives (ranked by desirability)✅ Option 1 — Upgrade
|
|
We cannot upgrade to 0.23.x tree-sitter as there are other language tree-sitters that are not yet upgraded to that version. |
|
Maybe an older version of |
|
Tested The npm package uses In short: No npm version of I've opened #516 to upgrade tree-sitter to 0.25.0 — once that lands, |
|
#83 also implements this. You could work together with @xFlaviews to deliver this language and I'm more than happy to merge your changes in. :) |
Add Dart as the 13th supported language across both gitnexus (Node.js) and gitnexus-web (WASM) packages. - Vendored tree-sitter-dart grammar (ABI 14) as optionalDependency with graceful try/catch loading (matching Swift pattern) - Tree-sitter queries: classes, mixins, extensions, enums, type aliases, functions, methods, constructors, getters/setters, imports, calls, heritage (extends/implements/with as trait-impl) - Dart import resolution: package: URIs, dart: SDK skip, relative imports - Flutter framework detection: path-based and AST-based patterns - Export detection: underscore-prefix convention (like Python) - Call graph: findEnclosingFunctionId Dart branches, Dart/Flutter BUILT_INS - Integration tests with try/catch guards for optional dependency
Addresses review feedback — adds trailing newline to supported-languages.ts (both packages) and removes trailing whitespace from tree-sitter-queries.ts.
…oint patterns - Add Flutter path-based framework detection to CLI (was only in web package) - Wire Flutter AST patterns into AST_FRAMEWORK_PATTERNS_BY_LANGUAGE[Dart] - Fix scanConstructorBinding to handle selector_expression (User.named()) - Add Dart/Flutter entry-point name patterns (build, initState, dispose, runApp) - Add Dart/Flutter built-ins to noise filter (setState, Navigator, etc.) - Fix mixin_declaration query to use explicit field accessor (name:)
3f8ae6d to
b027ab8
Compare
|
Thanks for pointing to #83, @magyargergo — @xFlaviews did excellent work there, especially on type resolution. I've rebased onto the tree-sitter 0.25.0 upgrade (#516, now merged) and incorporated the best parts from both PRs: Adopted from #83:
Kept from this PR (not in #83):
Tree-sitter-dart dependency: Now using |
29a27ae to
41c7957
Compare
|
Claude finished @magyargergo's task in 1m 45s —— View job Tasks:
Recommended Tests for Dart Type ResolutionAfter reading the type extractor ( 1.
|
| Test Area | Current Coverage | Value |
|---|---|---|
extractDartForLoopBinding |
❌ 0 tests | High — 4 distinct paths |
await in pending assignment |
❌ 0 tests | High — common Dart pattern |
Named constructor in detectConstructorType |
❌ 0 tests | Medium |
| Missing literal variants (double, false, null) | Medium | |
| Generic type declarations | ❌ 0 tests | Medium |
const/final constructor |
❌ 0 tests | Low — likely works, good to confirm |
| End-to-end multi-tier dispatch | ❌ 0 tests | High — validates tier interaction |
For-loop element type resolution (3 tests): - Explicit typed loop variable (for (User u in users)) - Call iterable return type inference (for (var u in getUsers())) - Non-for_statement node rejection Await in pending assignments (2 tests): - Call result through await (var user = await getUser()) - Method call result through await (var user = await svc.fetch()) Virtual dispatch named constructor (2 tests): - Named constructor returns class name (Dog.unknown() → Dog) - Non-class callee returns undefined Literal type inference full coverage (4 tests): - double, false, null literals - Unknown node type returns undefined Generic and const declarations (3 tests): - Generic List<String> extracts outer type - Generic constructor call inference - const constructor call inference Total Dart tests: 88 (was 74)
|
Added the recommended type resolution tests: For-loop element type resolution (3 tests):
Await in pending assignments (2 tests):
Virtual dispatch — named constructor (2 tests):
Literal types full coverage (4 tests):
Generic and const declarations (3 tests):
Total Dart tests now: 88 (was 58 → +30 new tests covering all recommended gaps) Full local test suite: 113/114 pass, 4048 tests (1 pre-existing flaky lbug lock). |
|
@claude Let's run a final review if this PR is production ready and ready to be merged |
|
Claude finished @magyargergo's task in 3m 18s —— View job Final Production-Readiness ReviewTasks:
Verdict: ✅ Merge-ReadyCI is green (4320/4320 tests pass, tsc clean). All critical and high-severity issues from prior reviews have been resolved. The web module divergence is explicitly waived by @magyargergo. ✅ All Prior Issues Confirmed Resolved
Architecture Assessment — Solid
Test Coverage — Comprehensive
|
|
Would you help us with looking into splitting up the |
…name capture - Remove `add`, `close`, `emit` from global BUILT_IN_NAMES — `close` was previously removed intentionally for C POSIX, `add` hits Java/Python - Fix factory constructor query: use adjacency operator to capture variant name (`unknown`) not class name (`Dog`) in `factory Dog.unknown()` - Update test to assert exact factory constructor name capture
|
Addressed the remaining post-merge items from the review:
Regarding splitting |
|
@claude Let's run a final review if this PR is production ready and ready to be merged |
|
Claude finished @magyargergo's task in 2m 36s —— View job Tasks:
Final Production-Readiness ReviewVerdict: ✅ Merge-ReadyCI is green (4320/4320 tests pass, ✅ All Prior Issues Confirmed Resolved
Architecture Assessment — Solid
Test Coverage — Comprehensive (88 Dart-specific tests)
|
Four issues that were not addressed in PR abhigyanpatwari#204: 1. extractFunctionName: add function_signature/method_signature handlers and add both to FUNCTION_NODE_TYPES. Without this, findEnclosingFunctionId cannot resolve Dart function scopes — all calls inside Dart functions have no sourceId, breaking CALLS edge attribution. 2. formal_parameter_list: add to paramListTypes in extractMethodSignature. Dart's tree-sitter grammar uses this node type (not formal_parameters), so parameter counting returns 0 for all Dart functions. 3. Write-access queries: add @assignment patterns for obj.field = value and this.field = value. Without these, no ACCESSES write edges are emitted for Dart code. 4. initialized_identifier guard in extractDartDeclaration: comma-separated declarations (String a, b, c) produce initialized_identifier nodes which are in DART_DECLARATION_NODE_TYPES but were unhandled — the type lives on the parent node. Also adds Dart column to the feature matrix in type-resolution-system.md. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Hey @mrwogu @magyargergo — glad my type resolution work from #83 was useful! Since the maintainer suggested we collaborate and my Tier 0-2 type extractor was adopted directly, could a Co-Authored-By: Flavius flaviusmironcatalin@gmail.com be added? A code comment is appreciated but doesn't show up in GitHub contributions haha. Thanks! |
|
@xFlaviews i'll add you to the contributors when we release :) Thank you both for your contributions! I found one unhandled case but I'm now adding a fix to it in a separate PR :) |
Dart was added as the 14th supported language in PR abhigyanpatwari#204 but the README was not updated. Adds Dart row to the supported languages table and updates the language count from 13 to 14. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Dart was added as the 14th supported language in PR #204 but the README was not updated. Adds Dart row to the supported languages table and updates the language count from 13 to 14. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: close remaining Dart language support gaps Four issues that were not addressed in PR #204: 1. extractFunctionName: add function_signature/method_signature handlers and add both to FUNCTION_NODE_TYPES. Without this, findEnclosingFunctionId cannot resolve Dart function scopes — all calls inside Dart functions have no sourceId, breaking CALLS edge attribution. 2. formal_parameter_list: add to paramListTypes in extractMethodSignature. Dart's tree-sitter grammar uses this node type (not formal_parameters), so parameter counting returns 0 for all Dart functions. 3. Write-access queries: add @assignment patterns for obj.field = value and this.field = value. Without these, no ACCESSES write edges are emitted for Dart code. 4. initialized_identifier guard in extractDartDeclaration: comma-separated declarations (String a, b, c) produce initialized_identifier nodes which are in DART_DECLARATION_NODE_TYPES but were unhandled — the type lives on the parent node. Also adds Dart column to the feature matrix in type-resolution-system.md. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(dart): field-type resolution, call attribution, import resolution, and integration tests Fixes five Dart language support gaps with integration tests and architectural alignment: **Tree-sitter queries** — Add field declaration patterns for typed and nullable class fields (`String name = ''`, `String? name`). Without these, Dart class fields were invisible to the pipeline (zero Property nodes, zero HAS_PROPERTY edges). **Import resolution** — Dart relative imports (`import 'models.dart'`) don't use a leading `./`. The standard resolver only recognises paths starting with `.` as relative; bare paths fell through to a Java-style dot-to-slash conversion that mangled `models.dart` into `models/dart`. Fix: prepend `./` before calling resolveStandard. **Call attribution** — Dart's tree-sitter grammar places `function_body` as a sibling of `function_signature`, not as a child wrapping both. The `findEnclosingFunction` parent-walk never found the function because the call lives inside `function_body` which is a sibling of the signature. Fix: add `enclosingFunctionFinder` hook to LanguageProvider interface (following the same strategy pattern as `labelOverride`), with the Dart-specific logic in `languages/dart.ts`. Both `parse-worker.ts` and `call-processor.ts` consume the hook generically — no Dart-specific code in the generic processors. **Receiver chain extraction** — Add `unconditional_assignable_selector` to `MEMBER_ACCESS_NODE_TYPES` so `inferCallForm` returns `'member'` for Dart method calls. Add Dart-specific receiver extraction blocks in `extractReceiverName`, `extractReceiverNode`, and a `selector` handler in `extractMixedChain` for Dart's flat sibling-selector model (vs the nested member-expression model used by all other languages). **Integration tests** — New `dart.test.ts` with field-type resolution and call-result-binding describe blocks. Fixtures: `dart-field-types/` (models.dart + app.dart) and `dart-call-result-binding/` (models.dart + app.dart). 9 passing tests, 1 skipped (ACCESSES edges for field reads depend on type-env parameter binding propagation — tracked for follow-up). --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Gergo Magyar <gergomagyar@icloud.com>
|
Hey @magyargergo just noticed I'm not in the v1.4.9 contributors list 🙈 |
Now you are on ;) |
…i#525) Dart was added as the 14th supported language in PR abhigyanpatwari#204 but the README was not updated. Adds Dart row to the supported languages table and updates the language count from 13 to 14. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: close remaining Dart language support gaps Four issues that were not addressed in PR abhigyanpatwari#204: 1. extractFunctionName: add function_signature/method_signature handlers and add both to FUNCTION_NODE_TYPES. Without this, findEnclosingFunctionId cannot resolve Dart function scopes — all calls inside Dart functions have no sourceId, breaking CALLS edge attribution. 2. formal_parameter_list: add to paramListTypes in extractMethodSignature. Dart's tree-sitter grammar uses this node type (not formal_parameters), so parameter counting returns 0 for all Dart functions. 3. Write-access queries: add @assignment patterns for obj.field = value and this.field = value. Without these, no ACCESSES write edges are emitted for Dart code. 4. initialized_identifier guard in extractDartDeclaration: comma-separated declarations (String a, b, c) produce initialized_identifier nodes which are in DART_DECLARATION_NODE_TYPES but were unhandled — the type lives on the parent node. Also adds Dart column to the feature matrix in type-resolution-system.md. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(dart): field-type resolution, call attribution, import resolution, and integration tests Fixes five Dart language support gaps with integration tests and architectural alignment: **Tree-sitter queries** — Add field declaration patterns for typed and nullable class fields (`String name = ''`, `String? name`). Without these, Dart class fields were invisible to the pipeline (zero Property nodes, zero HAS_PROPERTY edges). **Import resolution** — Dart relative imports (`import 'models.dart'`) don't use a leading `./`. The standard resolver only recognises paths starting with `.` as relative; bare paths fell through to a Java-style dot-to-slash conversion that mangled `models.dart` into `models/dart`. Fix: prepend `./` before calling resolveStandard. **Call attribution** — Dart's tree-sitter grammar places `function_body` as a sibling of `function_signature`, not as a child wrapping both. The `findEnclosingFunction` parent-walk never found the function because the call lives inside `function_body` which is a sibling of the signature. Fix: add `enclosingFunctionFinder` hook to LanguageProvider interface (following the same strategy pattern as `labelOverride`), with the Dart-specific logic in `languages/dart.ts`. Both `parse-worker.ts` and `call-processor.ts` consume the hook generically — no Dart-specific code in the generic processors. **Receiver chain extraction** — Add `unconditional_assignable_selector` to `MEMBER_ACCESS_NODE_TYPES` so `inferCallForm` returns `'member'` for Dart method calls. Add Dart-specific receiver extraction blocks in `extractReceiverName`, `extractReceiverNode`, and a `selector` handler in `extractMixedChain` for Dart's flat sibling-selector model (vs the nested member-expression model used by all other languages). **Integration tests** — New `dart.test.ts` with field-type resolution and call-result-binding describe blocks. Fixtures: `dart-field-types/` (models.dart + app.dart) and `dart-call-result-binding/` (models.dart + app.dart). 9 passing tests, 1 skipped (ACCESSES edges for field reads depend on type-env parameter binding propagation — tracked for follow-up). --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Gergo Magyar <gergomagyar@icloud.com>
|
@magyargergo last mention sorry haha saw i'm not on the contributors list, any clue why? thank you very much man and sorry for the bother! |
You are on!
I just checked https://github.com/abhigyanpatwari/GitNexus/graphs/contributors |
|
I'm blind haha Thank you man!!! You're rocking!! |

Summary
gitnexus(Node.js CLI) andgitnexus-web(WASM browser) packagestree-sitter-dartgrammar regenerated with ABI 14 for compatibility withtree-sitter@0.21.0optionalDependencywith gracefultry/catchfallback (matching the Swift pattern)What's included
withas trait-impl)package:URI resolution (maps tolib/path),dart:SDK skip, relative import fall-throughmain.dart, screens, BLoC, services, widgets) and AST-based (StatelessWidget,StatefulWidget,BuildContext, etc.)_= private, like Python)findEnclosingFunctionIdDart-specific branches, Dart/FlutterBUILT_INSfor noise suppressionFiles changed (17 source + vendored grammar)
supported-languages.ts(both packages)tree-sitter-queries.ts,parsing-processor.ts,parse-worker.ts(both packages)parser-loader.ts(both packages)import-processor.ts,utils.ts(both packages)framework-detection.ts(both packages)package.json,package-lock.jsontree-sitter-languages.test.ts,simple.dartfixturevendor/tree-sitter-dart/(ABI 14 grammar)Test plan
npx tsc --noEmit— cleannpx vitest run— 851 tests pass (40 test files)Co-Authored-By: @xFlaviews