https://github.com/sake92/regenesca
Refactoring Generator of Source Code for Scala
https://github.com/sake92/regenesca
Last synced: 11 months ago
JSON representation
Refactoring Generator of Source Code for Scala
- Host: GitHub
- URL: https://github.com/sake92/regenesca
- Owner: sake92
- License: apache-2.0
- Created: 2024-09-02T13:51:27.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-07-16T10:11:58.000Z (about 1 year ago)
- Last Synced: 2025-07-17T12:06:49.304Z (about 1 year ago)
- Language: Scala
- Size: 85 KB
- Stars: 20
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Regenesca
Refactoring Generator of Source Code for Scala
"Refactoring" because it **does not blindly overwrite** previously generated files.
It only *changes what it needs to*.
This means you can **add your own code into the generated one**, as long as it *does not clash* with it.
The goal is to have a *minimally intrusive* code generator.
## How to use it?
See the [example](/example) folder
## How it works?
Regenesca is based on [Scalameta](https://scalameta.org/).
The principle is simple.
You tell it what *source code* should be contained in a *particular file*, and then:
- if file doesn't exist -> write that code into it
- if file exists -> merge the existing scala code in a *mostly ad-hoc* way to achieve 99% of what you wanted with your code generator
The merge looks roughly as follows:
- same-named `class` -> merge their contents
- same-named `object` -> merge their contents
- same-named `enum` -> overwrite it completely
- same-named `type` -> overwrite it completely
- same-named `val`/`var` -> overwrite it completely
- same-named `def` -> merge internally OR overwrite it completely (global flag)
- `import` is added if a same one doesn't exist
- `case`s are merged by their patterns
- comments are not preserved
- it ignores expressions when merging
## Adopters
- [Squery generator](https://github.com/sake92/squery) from version 0.6.0
- [OpenApi4s generator](https://github.com/sake92/openapi4s)