Skip to content

feat: add tree-sitter Dart support, replacing regex fallback#415

Open
superkim0610 wants to merge 2 commits intosafishamsi:v4from
superkim0610:feat/dart-tree-sitter
Open

feat: add tree-sitter Dart support, replacing regex fallback#415
superkim0610 wants to merge 2 commits intosafishamsi:v4from
superkim0610:feat/dart-tree-sitter

Conversation

@superkim0610
Copy link
Copy Markdown

@superkim0610 superkim0610 commented Apr 17, 2026

Summary

  • Upgrade extract_dart() from regex-only to a full tree-sitter extractor using tree-sitter-dart-orchard
  • Custom extractor to handle Dart-specific AST patterns: sibling-based method+body pairing (method_signature + function_body as siblings), selector-chain call detection (no call_expression node in Dart grammar)
  • Now extracts: classes, abstract classes, mixins, enums, extensions, constructors, methods, getters/setters, top-level functions, imports, inheritance (extends/with/implements), and call graphs
  • Previously regex could only capture class/function names and imports — no call graph, no inheritance edges

Changes

  • pyproject.toml — add tree-sitter-dart-orchard dependency
  • graphify/extract.py — replace regex extract_dart() with tree-sitter custom extractor
  • tests/fixtures/sample.dart — new test fixture
  • tests/test_languages.py — 10 new Dart tests

Test plan

  • 10 new Dart-specific tests (class, abstract class, mixin, enum, methods, function, imports, calls, no dangling edges)
  • All 100 language tests pass (90 existing + 10 new)
  • Tested on a 147-file Flutter project: 2562 nodes, 2682 edges, 181 call edges, 0 errors

Upgrade extract_dart() from regex-only to a full tree-sitter extractor
using tree-sitter-dart-orchard. Now extracts classes, mixins, enums,
extensions, functions, imports, inheritance, and call graphs.

- Add tree-sitter-dart-orchard dependency
- Custom extractor handling Dart's sibling-based method+body pairing
  and selector-chain call detection
- 10 new tests + sample.dart fixture
- Tested on 147-file Flutter project: 2562 nodes, 2682 edges, 0 errors
… walk_calls

- Merge identical branches in _extract_sig_name
- Convert walk_calls from recursion to iterative stack traversal
- Extract _link_supertype helper to deduplicate supertype resolution
- Extract _register_method helper to deduplicate method registration
- Remove unnecessary list(node.children) copies
- Add "imports_from" to clean_edges filter for consistency
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.

1 participant