Skip to content

processor: decouple codegen layer from builder internals (phase 0) - #299

Open
igel-devin-ai wants to merge 2 commits into
java-helpers:mainfrom
igel-devin-ai:devin/1790369750-codegen-decoupling
Open

igel-devin-ai wants to merge 2 commits into
java-helpers:mainfrom
igel-devin-ai:devin/1790369750-codegen-decoupling

Conversation

@igel-devin-ai

@igel-devin-ai igel-devin-ai commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Pure refactor, zero behavior change — decouples the code-generation layer inside processor so it no longer imports builder-specific internals. This is Phase 0 of extracting a reusable simple-codegen library (~40 files) into its own module/artifact: do the decoupling before any git mv so the move commits stay rename-safe.

  • ProcessingContext split: new AnnotationProcessingContext base (env/Elements/Types/logger/tracker + element helpers); ProcessingContext extends it and keeps only builder state (config reader, scope resolver, generator registry, formatter profile).
  • ProcessingLogger(processingEnv, debugEnabled) — reads no compiler enum itself; BuilderProcessor passes VERBOSE in.
  • New CompilerOption interface; CompilerArgumentsEnum implements it; readBuilderConfiguration() moved from CompilerArgumentsReader to BuilderConfigurationReader (static).
  • JavaLangAnalyser / JavaLangMapper / FieldAnnotationExtractor now take AnnotationProcessingContext; findConstructorForBuilder(type, markerAnnotation, ctx) is parameterized by the annotation class. New MapperOptions record carries copyTypeAnnotations + a generatedTypeResolver function into the mapper — replacing its context.getConfiguration() / getBuilderScopeResolver() reads.
  • New ClassCodeGenerator SPI + GenerationEnvironment in classgen; RoasterCodeGenerator implements ClassCodeGenerator; BuilderProcessor talks to the interface — the seam a future JavaPoet/custom backend plugs into.
  • PerformanceTracker is now a pure protocol interface. Phase names moved: ProcessingPhases (builder pipeline) + GenerationPhases (codegen sub-phases); ActivePerformanceTracker takes its display hierarchy at construction.

Rebased onto formatterProfile (#284): ProcessingContext still owns formatter creation (createSourceFormatter), but it's injected into the generator as a RoasterSourceFormatterFactory instead of the generator holding ProcessingContext — preserves the decoupled dependency direction while keeping the profile feature.

mvn test -pl processor: 428 tests, 0 failures.

devin-ai-integration Bot and others added 2 commits September 25, 2026 21:22
Prepares the code-generation layer for extraction into a separate
simple-codegen library. No file moves, no behavior change; only
dependency direction changes inside the processor module.

- AnnotationProcessingContext: new base class holding env/Elements/
  Types/logger/tracker + element helpers; ProcessingContext extends it
  and keeps builder-only state (config reader, scope resolver, registry)
- ProcessingLogger: takes debugEnabled flag instead of reading
  CompilerArgumentsEnum
- CompilerOption: new interface; CompilerArgumentsEnum implements it;
  CompilerArgumentsReader reads CompilerOption; readBuilderConfiguration
  moved to BuilderConfigurationReader
- JavaLangAnalyser/JavaLangMapper/FieldAnnotationExtractor: depend on
  AnnotationProcessingContext; findConstructorForBuilder takes the
  marker annotation class as a parameter; new MapperOptions carries
  copyTypeAnnotations + generated-type resolution into the mapper
- ClassCodeGenerator SPI + GenerationEnvironment introduced;
  RoasterCodeGenerator implements it; BuilderProcessor goes through the
  interface
- Phase constants split: ProcessingPhases (builder pipeline) +
  GenerationPhases (codegen sub-phases); PerformanceTracker is a pure
  protocol interface; ActivePerformanceTracker takes its phase
  hierarchy at construction

Co-Authored-By: Andreas Igel <andreas.igel@computacenter.com>
Co-Authored-By: Andreas Igel <andreas.igel@computacenter.com>
@devin-ai-integration
devin-ai-integration Bot force-pushed the devin/1790369750-codegen-decoupling branch from 353c73d to 4dde491 Compare September 25, 2026 21:23

This branch has not been deployed

No deployments
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.

1 participant