Repository navigation
processor: decouple codegen layer from builder internals (phase 0) - #299
Merged
AndreasIgel merged 6 commits intoOct 22, 2026
Merged
AndreasIgel merged 6 commits into
AndreasIgel merged 6 commits into
Conversation
devin-ai-integration
Bot
force-pushed
the
devin/1790369750-codegen-decoupling
branch
from
September 25, 2026 21:23
353c73d to
4dde491
Compare
devin-ai-integration
Bot
force-pushed
the
devin/1790369750-codegen-decoupling
branch
from
October 12, 2026 00:34
4dde491 to
df5d937
Compare
This was referenced Oct 12, 2026
devin-ai-integration
Bot
force-pushed
the
devin/1790369750-codegen-decoupling
branch
12 times, most recently
from
October 22, 2026 20:24
932eee2 to
574a6a1
Compare
devin-ai-integration
Bot
force-pushed
the
devin/1790369750-codegen-decoupling
branch
from
October 22, 2026 20:31
574a6a1 to
3c750be
Compare
Keep the assertThrows lambda wrapping only generateClass, so the expected exception is clearly attributed to the generation call.
The five constructor tests only need a compilable input to trigger the lazy profile initialization; a named constant states that intent.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Types.directSupertypes/Elements.getAllMembers return List<? extends X> by API design; same suppression the codebase already uses for such signatures.
The 'Factory for creating a source formatter' block lost its field when RoasterSourceFormatterFactory was removed.
The wildcard return types are enforced by Types.directSupertypes and Elements.getAllMembers, not a design choice.
|
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.



Summary
Closes #347. Part of #233.
Pure refactor, zero behavior change — decouples the code-generation layer inside
processorso it no longer depends on builder-specific internals. This is Phase 0 of extracting a reusablesimple-codegenlibrary (~40 files) into its own module/artifact: do the decoupling before anygit mvso the move commits stay rename-safe.ClassCodeGeneratorSPI (new):BuilderProcessornow talks to the generator through the interface.RoasterCodeGenerator implementsit and receives aGenerationEnvironment(processing environment, logger, performance tracker,GenerationIssueReporter) instead of the wholeProcessingContext; the caller passes a genericSourceFormatterpergenerateClasscall (resolved and cached per formatting mode bySourceFormatterResolver, which owns theformatterProfilecompiler argument). Strict-mode reporting keeps its semantics viacontext::reportBasedOnStrictModewired as the issue reporter.CodeGenerationException(new): the code generation layer's own checked failure type —ClassCodeGenerator.generateClassandRoasterCodeGeneratorno longer declare or throw the builder-specificBuilderException. The "builder class already exists" pre-check moved out of the generator intoBuilderProcessor(assertTargetClassDoesNotExist), whereBuilderExceptionnaturally lives; callers wrapCodeGenerationExceptionat the boundary.classgennow imports zero builder-side exception types.TypeMappingContextinterface (new): exposes exactly the functions the type mapper needs (javax.lang.modellookups likegetTypeElement,asElement,erasure,isAssignable,isSameType,directSupertypes,getPackageName,getAllMembers, plusisAccessibleFromGeneratedPackage,debug,shouldCopyTypeAnnotationsandresolveGeneratedType).ProcessingContextimplements it, so mapper signatures collapse back to(element, context)— the builder scope resolver and the builder configuration are no longer visible to the mapper. The interface is what moves intosimple-codegenin phase 1.findConstructorForBuildertakes the constructor marker annotation as a parameter instead of hardcodingSimpleBuilderConstructor(the builder caller passes it in).ProcessingLoggerno longer reads compiler options itself: the constructor is private behind thecreate(env)/createVerbose(env)named factories over a privateVerbosityenum — callers pick the variant by intent; the-Averboseoption is read once inBuilderProcessor.CompilerOptioninterface (new) decouplesCompilerArgumentsReaderfrom the builder option enum;readBuilderConfigurationmoved toBuilderConfigurationReadernext to the other configuration sources.PerformanceTracker(now a pure protocol) intoProcessingPhases(pipeline phases + hierarchy) andGenerationPhases(codegen sub-phases);ActivePerformanceTrackertakes them as constructor arguments.Out of scope (next PRs)
ProcessingContextinto a genericAnnotationProcessingContext+ builder-specific context (separate PR — it touches many files on its own).git mvof the decoupled classes intosimple-codegen/simple-codegen-roastermodules (Phase 1).Test plan
mvn test -pl processor— all 528 tests passmvn -pl example clean compile— regeneratedgenerated-example-builder/tree is byte-identical (confirms zero behavior change)license:check— all new files carry the license header