19 refactor config generator to be much more strongly typed - #42
Open
bristermitten wants to merge 29 commits into
Open
19 refactor config generator to be much more strongly typed #42bristermitten wants to merge 29 commits into
bristermitten wants to merge 29 commits into
Conversation
…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.
…vaPoet statement nesting/generic casting
… to avoid duplicate bindings
…erializers, and fix tests
…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
…and default values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.