feat: add Dart/Flutter language support#83
Conversation
|
@xFlaviews is attempting to deploy a commit to the NexusCore Team on Vercel. A member of the Team first needs to authorize it. |
|
Thanks for this, will review |
|
working on our social network and as we are using flutter i couldn't use the tool haha thank you! lmk if it needs any changes |
PR #83 Review: Dart/Flutter Language Support+286 / -0 across 11 files Well-structured PR that follows the existing 6-layer language support architecture. The contributor clearly studied how the other 10 languages were added. However, there are several issues that need to be addressed before merging. CRITICAL / BUGSBUG-1: The PR description itself warns that the published npm package uses legacy BUG-2: In BUG-3: No name-extraction logic for
ISSUESISSUE-1 (High): Method calls query is dead code — missing This has ISSUE-2 (Medium): Direct/return/assignment call queries are context-limited The call queries only match calls inside ISSUE-3 (Medium): Dart import resolution differs subtly between the two code paths
ISSUE-4 (Low): Mixin heritage uses Dart mixins are semantically closer to Rust traits / PHP traits. Using STYLE / CONSISTENCY
SUGGESTIONS
Summary
Verdict: The architecture and approach are solid — the contributor clearly understands the project's patterns. But the PR needs a revision pass to fix the critical dependency issue, the silent method-call capture drop, and the main-thread/worker-thread inconsistencies before it's merge-ready. |
…, postinstall - Add init_declaration/deinit_declaration to call-processor FUNCTION_NODE_TYPES and findEnclosingFunction (syncs with parse-worker, avoids Dart PR abhigyanpatwari#83 rejection) - Add 7 missing CodeRelation FROM-TO pairs in schema.ts to eliminate analyze warnings (Function→Property, Constructor→Property/Typedef, Enum→Class/Interface, Struct→Interface, TypeAlias→Class) - Mirror all Swift support to gitnexus-web: supported-languages, utils, queries, framework-detection, entry-point-scoring, parser-loader WASM path - Add postinstall script to patch tree-sitter-swift binding.gyp actions array
|
Can you please review the |
|
Hi! I'm a Flutter developer and really looking forward to this Dart/Flutter support. 🙏 My team is actively building a Flutter app and we'd love to use GitNexus to improve our AI-assisted development workflow — tracking call chains, analyzing impact before changes, and mapping out payment/business logic across our codebase. Right now without Dart support, GitNexus essentially skips all our core code, which makes it unusable for pure Flutter projects. Is there anything the community can help with to move this forward? Happy to test on our real-world Flutter project once the issues from the review are addressed. Really excited about this feature — great work @xFlaviews! 🚀 |
|
nice work! |
|
@xFlaviews could you please rebase your work on the main branch? 🙏 |
|
@k1r3zz hi, would u be willing to join our discord. We are getting a initial batch of clients to try out our enterprise version for relatively less pricing so we can improve on it. Feel free to dm me if thats ok |
Full Dart/Flutter integration into the LanguageProvider architecture: - Language registration: SupportedLanguages enum, language detection, parser loader, provider registry with compile-time exhaustiveness - Tree-sitter queries: classes, mixins, enums, extensions, type aliases, functions, methods, imports, exports, calls, heritage (extends/implements/with) - Type extractor (450 lines): Tier 0 explicit declarations & parameters, Tier 1 constructor inference (incl. named constructors, virtual dispatch, literal types), Tier 2 assignment chain propagation (copy, callResult, fieldAccess, methodCallResult), for-loop element type resolution, null-safe (?.) and await support - Import resolution: dart: SDK (skip), package: (pubspec.yaml), relative - Export detection: underscore-prefix convention (_private) - Framework detection: Flutter widgets, Riverpod providers, lifecycle methods - Entry point scoring: main, build, initState, dispose, createState patterns - Noise filtering: Dart/Flutter built-ins (print, setState, runApp, etc.) - AST helpers: mixin_declaration, extension_declaration container types Includes postinstall script (scripts/patch-tree-sitter-dart.cjs) that converts tree-sitter-dart@1.0.0 from NAN to NAPI bindings for worker_threads compatibility — NAN modules fail with "Module did not self-register" when loaded concurrently across worker threads alongside NAPI-based parsers. Rebased on upstream/main (LanguageProvider architecture refactoring). Tested on waveful_app (731 Dart files): 265K nodes, 825K edges indexed. Zero TypeScript errors, zero regressions for existing languages. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
c18d3a3 to
8d93354
Compare
let me know how if we need anything else |
|
@claude ultra-think while identifying Dart/Flutter-language gaps. Perfom 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 perpective and review the architectural fit. Also check out previous comments and reason with their requests. |
|
Claude finished @magyargergo's task in 5m 10s —— View job Dart/Flutter Language Support — Senior Compiler/Static Analysis ReviewReviewed by: @claude (acting as senior compiler front-end engineer / static analysis expert) Tasks
Previous Review Status
New Findings (not in previous review)🔴 NEW-BUG-1 —
|
| Feature | Dart |
|---|---|
| Declarations | Yes |
| Parameters | Yes (partial — nullable gap) |
| Initializer / constructor inference | Yes |
| Constructor binding scan | Yes |
| For-loop element types | Yes |
| Pattern binding | No |
| Assignment chains | Yes |
| Write access (ACCESSES write) | No (missing queries) |
Also, the document's "Supported Languages" section says "13 languages" and lists them; Dart should be added as the 14th.
Addressing @magyargergo's type-resolution-system.md Request
@magyargergo asked for implementation following type-resolution-system.md. This PR does implement the required tiers:
- Tier 0 (
extractDartDeclaration,extractDartParameter) — correct, well-structured - Tier 0b for-loop (
extractDartForLoopBinding) — thorough, handlesawaititerables - Tier 1 constructor inference (
extractDartInitializer,detectDartConstructorType) — correct, validates againstClassNameLookup - Tier 2 fixpoint (
extractDartPendingAssignment) — correctly covers copy/fieldAccess/callResult/methodCallResult - Literal types (
inferDartLiteralType) — complete for Dart primitives
The implementation quality is above average for a new language — Swift was the previous addition and it remains "the most minimal" by the doc's own admission. Dart's extractor is more complete than Swift's.
The remaining gaps (nullable types, initialized_identifier) are medium-priority refinements.
Architecture Observations
Patch script is the right pattern — mirrors patch-tree-sitter-swift.cjs exactly, including idempotency checking and graceful degradation. The postinstall hook approach is pragmatic for this NAN→NAPI incompatibility. Long-term the right fix is upstream, but this works.
Import resolver is clean — no duplication, proper null returns for SDK/external packages, correct pubspec.yaml parsing. One edge case: package:myapp/ imports that lack a root package match fall through silently to null (correct), but if pubspec.yaml doesn't exist, all package: imports resolve to null. Consider a log warning in dev mode for discoverability.
Query structure: Three of the four Dart call queries (expression_statement, return_statement, initialized_variable_definition) are context-anchored patterns. Most mature language implementations use flat call_expression / call_expression node queries that match anywhere in the tree. The context-anchoring approach misses calls inside if conditions, while conditions, list literals, and argument positions. This is ISSUE-2 from the original review and remains open.
Priority Summary
| Priority | Issue | Fix Complexity |
|---|---|---|
| 🔴 Critical | NEW-BUG-1: @definition.function on program node |
1-line query fix |
| 🔴 Critical | ISSUE-1: Method calls dead code (no outer @call) |
Query rewrite |
| 🔴 Critical | BUG-3: extractFunctionName null for function_signature |
~10-line branch in ast-helpers.ts |
| 🔴 Critical | NEW-BUG-2: Missing write-access queries | Add 2 query patterns |
| 🟠 High | ISSUE-4: Mixin with maps to kind: 'implements' |
Rename one capture |
| 🟡 Medium | NEW-ISSUE-1: initialized_identifier unhandled |
Extractor guard fix |
| 🟡 Medium | NEW-ISSUE-2: Nullable type bypass | hasDartTypeAnnotation fix |
| 🟡 Medium | NEW-ISSUE-3: feature matrix not updated | Doc update |
| 🟢 Low | ISSUE-2: Context-anchored call queries miss many call sites | Query restructure |
Overall: the architecture is solid and the type-extractor implementation quality is good. The four critical issues (query bugs) are straightforward fixes — the codebase patterns make the correct solutions obvious from the surrounding language implementations.
|
@xFlaviews can you please look at them? 🙏 |
…ution, broader detection Incorporate improvements from @xFlaviews' PR abhigyanpatwari#83: Type extractor (replaced stub with full implementation): - Tier 0: explicit type annotations with nullable_type unwrapping - Tier 1: constructor/initializer inference via parseDartRHS() - Tier 2: assignment chain propagation (copy/fieldAccess/callResult/methodCallResult) - For-loop element type resolution with await support - Virtual dispatch detection, literal type inference Language provider: - Set importSemantics to 'wildcard' (Dart imports bring everything public) Framework detection: - Broader path patterns: removed /lib/ prefix requirement, added app.dart, routes/, views/, presentation/, domain/ - Added Riverpod AST patterns (ref.watch, ref.read, AsyncNotifier, Notifier) - Added ConsumerWidget to Flutter AST patterns Entry-point scoring: - Added main, createState, class-suffix patterns (Widget$, Page$, Screen$, Controller$, Notifier$, Provider$) Tree-sitter queries: - Added call capture in return statements and variable assignments - Added re-export query (library_export) Noise filter: - Added deactivate, reassemble, debugDumpApp, debugDumpRenderTree
…ution, broader detection Incorporate improvements from @xFlaviews' PR abhigyanpatwari#83: Type extractor (replaced stub with full implementation): - Tier 0: explicit type annotations with nullable_type unwrapping - Tier 1: constructor/initializer inference via parseDartRHS() - Tier 2: assignment chain propagation (copy/fieldAccess/callResult/methodCallResult) - For-loop element type resolution with await support - Virtual dispatch detection, literal type inference Language provider: - Set importSemantics to 'wildcard' (Dart imports bring everything public) Framework detection: - Broader path patterns: removed /lib/ prefix requirement, added app.dart, routes/, views/, presentation/, domain/ - Added Riverpod AST patterns (ref.watch, ref.read, AsyncNotifier, Notifier) - Added ConsumerWidget to Flutter AST patterns Entry-point scoring: - Added main, createState, class-suffix patterns (Widget$, Page$, Screen$, Controller$, Notifier$, Provider$) Tree-sitter queries: - Added call capture in return statements and variable assignments - Added re-export query (library_export) Noise filter: - Added deactivate, reassemble, debugDumpApp, debugDumpRenderTree
…ution, broader detection Incorporate improvements from @xFlaviews' PR abhigyanpatwari#83: Type extractor (replaced stub with full implementation): - Tier 0: explicit type annotations with nullable_type unwrapping - Tier 1: constructor/initializer inference via parseDartRHS() - Tier 2: assignment chain propagation (copy/fieldAccess/callResult/methodCallResult) - For-loop element type resolution with await support - Virtual dispatch detection, literal type inference Language provider: - Set importSemantics to 'wildcard' (Dart imports bring everything public) Framework detection: - Broader path patterns: removed /lib/ prefix requirement, added app.dart, routes/, views/, presentation/, domain/ - Added Riverpod AST patterns (ref.watch, ref.read, AsyncNotifier, Notifier) - Added ConsumerWidget to Flutter AST patterns Entry-point scoring: - Added main, createState, class-suffix patterns (Widget$, Page$, Screen$, Controller$, Notifier$, Provider$) Tree-sitter queries: - Added call capture in return statements and variable assignments - Added re-export query (library_export) Noise filter: - Added deactivate, reassemble, debugDumpApp, debugDumpRenderTree
…ution, broader detection Incorporate improvements from @xFlaviews' PR abhigyanpatwari#83: Type extractor (replaced stub with full implementation): - Tier 0: explicit type annotations with nullable_type unwrapping - Tier 1: constructor/initializer inference via parseDartRHS() - Tier 2: assignment chain propagation (copy/fieldAccess/callResult/methodCallResult) - For-loop element type resolution with await support - Virtual dispatch detection, literal type inference Language provider: - Set importSemantics to 'wildcard' (Dart imports bring everything public) Framework detection: - Broader path patterns: removed /lib/ prefix requirement, added app.dart, routes/, views/, presentation/, domain/ - Added Riverpod AST patterns (ref.watch, ref.read, AsyncNotifier, Notifier) - Added ConsumerWidget to Flutter AST patterns Entry-point scoring: - Added main, createState, class-suffix patterns (Widget$, Page$, Screen$, Controller$, Notifier$, Provider$) Tree-sitter queries: - Added call capture in return statements and variable assignments - Added re-export query (library_export) Noise filter: - Added deactivate, reassemble, debugDumpApp, debugDumpRenderTree
|
Thank you for your contribution! This has been superseded by #204. |
|
ah was working on the changes you asked haha and some improvements haha, dope! created a new PR addressing other flaws #524 also |
…, postinstall - Add init_declaration/deinit_declaration to call-processor FUNCTION_NODE_TYPES and findEnclosingFunction (syncs with parse-worker, avoids Dart PR abhigyanpatwari#83 rejection) - Add 7 missing CodeRelation FROM-TO pairs in schema.ts to eliminate analyze warnings (Function→Property, Constructor→Property/Typedef, Enum→Class/Interface, Struct→Interface, TypeAlias→Class) - Mirror all Swift support to gitnexus-web: supported-languages, utils, queries, framework-detection, entry-point-scoring, parser-loader WASM path - Add postinstall script to patch tree-sitter-swift binding.gyp actions array
Summary
Adds comprehensive Dart/Flutter support to GitNexus as the 11th supported language, following the existing 6-layer language support architecture.
package:URI imports (resolved viapubspec.yaml),_prefix visibility, Flutter widget lifecycle, mixin heritageWhat's included
DartinSupportedLanguagestree-sitter-dartgrammar (main + worker threads).dart→SupportedLanguages.Dartpackage:URI), exports, 4 call patterns (direct, method, return, assignment), heritage (extends, implements, with)package:<name>/path.dart→lib/path.dart, relative imports, skipdart:SDK_prefix = private, no prefix = publicmain.dart(3.0×), pages/screens/views (2.5×), routes (2.5×), presentation (2.0×), widgets (1.5×)main,build,initState,dispose,createState,*Widget,*Page,*Screen,*Controller,*Notifier,*ProvidersetState,initState,dispose,runApp,print,debugPrint, etc.tree-sitter-dartnpm packageThe published
tree-sitter-dart@1.0.0on npm uses legacynannative bindings, which are incompatible withtree-sitter@^0.21.0(requiresnode-addon-api/ NAPI).Workaround: rebuild from source:
Long-term fix: publish a NAPI-compatible version of
tree-sitter-dart, or vendor the rebuilt grammar.Test results
Analyzed a production Flutter codebase (~1,200 Dart files):
Heritage (extends/implements/with), imports, and call graphs all resolve correctly. Verified against sample files with mixins (both
withandextends ... with),package:imports, and nested method calls.Test plan
npx tsc --noEmit)package:imports resolve correctly via pubspec.yamldart:SDK imports are skippedwithmixins all resolve_prefix correctly marks symbols as private🤖 Generated with Claude Code