{"id":15487748,"url":"https://github.com/werediver/dart-reptr-rs","last_synced_at":"2025-07-19T03:36:19.131Z","repository":{"id":63151051,"uuid":"565581647","full_name":"werediver/dart-reptr-rs","owner":"werediver","description":"Fast code generation for Dart. Eventually. Maybe.","archived":false,"fork":false,"pushed_at":"2023-09-20T17:40:32.000Z","size":146,"stargazers_count":5,"open_issues_count":2,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-19T07:54:29.115Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/werediver.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-13T21:06:59.000Z","updated_at":"2024-10-14T07:38:12.000Z","dependencies_parsed_at":"2025-03-04T02:32:51.842Z","dependency_job_id":null,"html_url":"https://github.com/werediver/dart-reptr-rs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/werediver%2Fdart-reptr-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/werediver%2Fdart-reptr-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/werediver%2Fdart-reptr-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/werediver%2Fdart-reptr-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/werediver","download_url":"https://codeload.github.com/werediver/dart-reptr-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250289744,"owners_count":21406050,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T06:41:37.844Z","updated_at":"2025-04-22T17:45:21.131Z","avatar_url":"https://github.com/werediver.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Validation](https://github.com/werediver/dart-reptr-rs/actions/workflows/validation.yaml/badge.svg?event=push\u0026branch=main)](https://github.com/werediver/dart-reptr-rs/actions/workflows/validation.yaml)\n\n# Dart repointer\n\nDart repointer (`reptr`) ~~puts the sharp part in your Dart~~ aims to facilitate _fast_ code generation for Dart. It consists of [the tool itself](reptr/) and a [Dart parser library](dart-parser).\n\n## Motivation\n\n`build_runner`-based code generation for a single package can take a couple minutes. This translates to unreasonably long code generation time for large Dart and Flutter projects (e.g. over 45 minutes 🤯). This is predominantly due to inefficiencies in the code generation infrastructure, the `build_runner`. A faster implementation should allow 20–50x speed-up.\n\n## Project structure\n\nThe key components of this project that are already functional are:\n\n- Filesystem scanner\n  - Identifies Dart packages and source files on the filesystem\n- File loader\n  - Loads a file into memory, performs UTF-8 validation\n- Parser (lexerless)\n  - Constructs an abstract syntax tree from the loaded Dart code\n\n```mermaid\nflowchart LR\n  CLI --\u003e Scanner[F/s scanner] --\u003e Loader --\u003e Parser[\"Parser\\n(lexerless)\"] --\u003e Gen1 \u0026 Gen2 --\u003e Combiner --\u003e Writer --\u003e Formatter[External formatter]\n\n  CLI --\u003e Reporter[Status / progress reporter]\n\n  CLI --\u003e Watcher[F/s watcher]\n\n  subgraph Generator 1\n    Gen1[...]\n  end\n\n  subgraph Generator 2\n    Gen2[...]\n  end\n\n  style Reporter stroke-dasharray: 5 5\n  style Watcher stroke-dasharray: 5 5\n  style Gen1 stroke-dasharray: 5 5\n  style Gen2 stroke-dasharray: 5 5\n  style Combiner stroke-dasharray: 5 5\n  style Writer stroke-dasharray: 5 5\n  style Formatter stroke-dasharray: 5 5\n```\n\n## Design notes\n\n- Loading source files\n  - Loading the complete file for parsing is fine\n  - Memory-mapping is not faster per se\n    - May play nicely with a lazy tokenizer with lazy UTF-8 validation\n- Parsing\n  - The parser is a _partial_ parser: it recognizes certain parts of the target language and can skip over the rest\n  - Capturing slices of the source (`\u0026str`) is extremely cheap (doesn't cause memory allocation), so take advantage of that\n  - When feasible, avoid memory allocation (namely, the use of `Vec` and co.)\n  - When implementing a parser as a function\n    - Do not start parsing with whitespace\n      - E.g. the import-stmt. parser should start with consuming `import`, not whitespace\n    - Do not consume the trailing whitespace after a construct (e.g. in `import 'dart:math';\\n\\n` do not consume `\\n\\n`)\n  - When combining parsers\n    - Prefer consuming whitespace in trailing position, not leading\n- A tempting feature: in-place code generation / code transformation\n  - Requires accurate back-to-source transformation\n- Output formatting\n  - Delegate to [dart format](https://dart.dev/tools/dart-format) (it's fast enough)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwerediver%2Fdart-reptr-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwerediver%2Fdart-reptr-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwerediver%2Fdart-reptr-rs/lists"}