Skip to content

19 refactor config generator to be much more strongly typed - #42

Open
bristermitten wants to merge 29 commits into
masterfrom
19-refactor-config-generator-to-be-much-more-strongly-typed-
Open

19 refactor config generator to be much more strongly typed #42
bristermitten wants to merge 29 commits into
masterfrom
19-refactor-config-generator-to-be-much-more-strongly-typed-

Conversation

@bristermitten

Copy link
Copy Markdown
Owner

No description provided.

bristermitten and others added 29 commits June 14, 2026 20:25
…ilder DSL

Introduce a new `codegen-dsl` module to replace the verbose and unsafe JavaPoet builder API with a Scala-native, type-safe DSL.

Key architectural highlights:
- Defined a robust AST (`Ast.scala`) modeling Java classes, fields, methods, variables, and expressions (`Expr`).
- Added a `BlockBuilder` context using Scala 3's context parameters (`using BlockBuilder`), providing a clean monadic-like block expression builder without requiring manual chain building.
- Replaced stringly-typed statements with typed AST expressions (e.g., `Expr.MethodRef`, `Expr.StaticMethodRef`), completely removing raw literal string interpolation and reducing runtime syntax/semantic errors in generated code.
- Added `CodeBlockRenderer` to translate the Scala AST into high-quality JavaPoet `CodeBlock` objects, acting as a clean translation layer.
- Added JUnit/ScalaTest coverage under `BlockBuilderTest.scala` to verify AST correctness and scoped variable declaration tracking.
… to Scala and codegen-dsl

Port the entire annotation processor code generation pipeline from JavaPoet to Scala, rewriting all generators to utilize the new type-safe `codegen-dsl`.

Key improvements & details:
- Replaced the stringly-typed and fragile JavaPoet generators in `annotation-processor/src/main/java/me/bristermitten/mittenlib/annotations/compile` with type-safe Scala equivalents using `codegen-dsl`.
- Leverage Scala 3's context-bound `(using BlockBuilder)` pattern to simplify nested code generation scopes (deserializers, validators, and serializers).
- Fixed compiler crash issues during compilation of newly annotated types by removing strict reflection/class loading validation from the AST constructors.
- Migrated support classes (`TypesUtil`, `NewtypeUtil`) to improve interop and type safety.
- Verified functional correctness against existing tests (e.g. `NewtypeValidationTest`).
…rators to Scala and codegen-dsl

Re-implement the boilerplate generator processor for record and union classes in Scala, completing the migration of all code generation subprojects.

Key changes:
- Replaced the legacy Java classes in `record-generator/processor/src/main/java/me/bristermitten/mittenlib/codegen/` with Scala 3 equivalents under `src/main/scala/`.
- Rewrote the main annotation processor `MittenLibCodegenProcessor` to compile under the Scala toolchain.
- Standardized the generated output templates (e.g. `UnionGenerator`, `RecordGenerator`, `MatchGenerator`, and `BoilerplateGenerator`) using the type-safe `codegen-dsl`.
- Represented AST elements like `UnionSpec` and `RecordSpec` as Scala case classes to clean up representation logic and eliminate raw boilerplate.
- Ensured generated classes continue to target Java 8 runtime compliance, maintaining compatibility.
…nding

Simplify dependency injection binding logic within `ConfigDataModule`.

Key changes:
- Replaced the verbose `TypeLiteral` instantiation with a direct `Key` binding in the configuration provider.
- Restructured configuration bootstrapping dependency registration to align with modern Guice injection patterns and clean up type handling.
…primitives in union matching, and suppress FutureReturnValueIgnored warning
…ollection and map types during validation code generation
…nd fix Scala joint compilation APT issues
…nerate the processor service registration file
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