Skip to content

Added flutter/dart support - #130

Merged
anhnh2002 merged 15 commits into
FSoft-AI4Code:mainfrom
majmohar4:main
Oct 12, 2026
Merged

anhnh2002 merged 15 commits into
FSoft-AI4Code:mainfrom
majmohar4:main

Conversation

@majmohar4

Copy link
Copy Markdown
Contributor

Add Dart / Flutter support

Adds a Dart analyzer so CodeWiki can document Dart and Flutter projects. .dart files go through the same dependency-analysis and doc-generation pipeline as the other languages.

What's included

Core Dart analysis (analyzers/dart.py, analyzers/dart_imports.py)

  • Classes, mixins, extensions, enums, top-level functions/getters and methods become components.
  • Edges for inheritance (extends / with / implements), field types, instantiations and calls.
  • package: and relative imports, exports and part/part of files decide which definition a name resolves to.
  • Library-private (_name) declarations never resolve outside their library.
  • Names not visible through imports are dropped instead of guessed, so there are no cross-language false matches (e.g. Row resolving to a Kotlin class).
  • Extension method calls are routed through the extension's on type, and this.field receivers are resolved.

Flutter-aware edges (analyzers/dart_flutter.py)

  • Widgets and State classes are typed, and instantiations inside build() become widget-to-widget edges.
  • ref.watch / ref.read link widgets to Riverpod providers, including @riverpod codegen.
  • GoRouter routes link to their screen widgets.
  • Dart modules get Flutter-specific documentation hints in the prompt.

Robustness

  • Generated files (*.g.dart, *.freezed.dart, etc.) and .dart_tool/ are ignored.
  • Dart 3.8 null-aware collection elements (?x) are blanked before parsing, because the bundled grammar doesn't support them yet. Byte positions are unchanged.

Other changes

  • tree-sitter-language-pack is pinned to >=0.8.0,<0.9.0. The Dart grammar/API in 0.9 is not yet verified.
  • README, CHANGELOG and guides/development.md are updated.
  • .dart is added to the CLI/MCP language validation.

Testing

  • New tests: tests/test_dart_analyzer.py, tests/test_dart_flutter.py, tests/test_dart_imports.py, tests/test_doc_layout.py. All 62 pass.
  • Tried on real Flutter apps using Riverpod and GoRouter.

Notes for reviewers

  • Only call_graph_analyzer.py changes in a significant way (+156 lines) ou, to register the analyzer and the Dart file handling.

majmohar4 and others added 15 commits October 7, 2026 16:32
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Also document Dart/Flutter support in README, CHANGELOG and the dev guide.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The bundled grammar predates null-aware collection elements, which broke
parsing of whole files. The '?' is replaced with a space so positions stay
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Unresolved Dart callees no longer fall back to repo-wide or cross-language
name matching (Size bound to the Windows runner header, Row to Kotlin).
Private members of private classes stay inside their library. Drift's
_$X bases are no longer treated as notifiers, unnamed extensions get
unique ids, annotations are kept in snippets, more generated files are
ignored, and tree-sitter-language-pack is capped below 0.9.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Scoped resolution merged exact and short-name index hits before
requiring a unique match, so an imported top-level helper() became
ambiguous with any visible Tool.helper method and the edge was dropped.
Try exact names first and only widen to short names when nothing
matched exactly, which also mirrors Dart's lexical-before-this lookup.
package: URIs map to repository files through pubspec.yaml. When none is
in the analyzed tree (e.g. only lib/ was analyzed), every import resolved
to nothing while callers were still treated as scoped, so almost every
cross-file edge was silently dropped. Keep library-private scoping, but
match public names across all Dart files in that case and log a warning.
Dart resolution stays authoritative either way, so there is still no
cross-language guessing.
The pattern targets injectable's generated injection.config.dart, but
hand-written files such as app.config.dart are common and were silently
excluded. Dropping one generated file's noise is not worth losing user
code; users can still exclude it explicitly.
@anhnh2002

Copy link
Copy Markdown
Collaborator

Thanks a lot for this, @majmohar4. I pushed three small commits on top of your branch (hope that's OK):

  1. Exact names before short names in scoped resolution (3be8974). _dart_scope_candidates merged exact and short-name hits before requiring one unique match. So an imported top-level helper() became ambiguous whenever any visible class also had a helper method, and the edge was dropped. Exact names are now tried first, which also matches Dart's own lookup order.
  2. Fallback when there's no pubspec.yaml (54e7d7b). If CodeWiki is run on e.g. myapp/lib, package: imports can't be mapped to files. Every caller was still treated as scoped, so almost all cross-file edges disappeared without any warning. In that case we now keep the library-private rules, match public names across Dart files only, and log a warning.
  3. Dropped *.config.dart from the default ignores (9d8c538). It catches injectable's generated file, but hand-written app.config.dart-style files are common and were being skipped.

Left for follow-ups:

  • show/hide combinators aren't applied yet, so a hidden name can still make a lookup ambiguous. That needs per-import name filters.
  • For conditional imports, keeping only the default URI is the right call. Adding the platform variants would make every shared name ambiguous.
  • Scope sets are stored per file, so memory grows roughly with files² in very large apps with barrel files. Sharing them per import set would fix it.

@anhnh2002
anhnh2002 merged commit 966f4cd into FSoft-AI4Code:main Oct 12, 2026
2 checks passed
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.

2 participants