Skip to content

Genericize codegen seams; keep builder model processor-side (prep for #349) #369

Closed

Description

@igel-devin-ai

Preparatory step for #349, before the model move lands.

Goal: simple-codegen must contain only framework-agnostic codegen — no builder vocabulary. Generation consumes only the generic base (GenerationTargetClassDto); the builder-domain layer stays processor-side.

Seam changes (interfaces to genericize first)

  • TypeMappingContext.resolveGeneratedType — currently Optional<ResolvedBuilder>; needs a neutral return (Optional<TypeName> or a generic generated-type ref). Design needed for what ResolvedBuilder.buildCall(...)/setterPrefix provide to callers (builder instantiation emission).
  • TypeName.resolvedBuilder field — neutral type + name.
  • BuilderInstantiation — generic instantiation-strategy vocabulary (ConstructorCall/StaticFactoryCall are generic-shaped; AnchorFactoryCall is builder-specific).
  • GeneratedBuilders registry — generic generated-types registry (Map<TypeName, TypeName> semantics already).

Builder model placement

Builder-domain types stay processor-side (processor.model), never move to codegen: BuilderConfiguration, BuilderDefinitionDto, BuilderMethodDto, BuilderNestedTypeDto, BuilderToGenerationTypeMapper, ResolvedBuilder, BuilderInstantiation, GeneratedBuilders.

Preference order for modelling the split: separate type + mapping > composition > inheritance (last resort). Builder DTOs may freely use codegen vocabulary (TypeName, FieldDto, MethodDto) as field types or produce them at the boundary (BuilderToGenerationTypeMapper → GenerationTargetClassDto at finalization, as today). Where a builder type needs generic-shaped state, prefer holding it (BuilderDefinitionDto already holds/produces a GenerationTargetClassDto) over inheriting it — inheritance between the two model families only if neither mapping nor composition fits. (Extending a DTO to add a property remains a good pattern; this rule targets model-family hierarchies, not the extends mechanism.)

Genuine duplication only where codegen cannot see the other side (anti-corruption seam): the codegen.enums mirror of core.enums is the pattern — correct for the future repo split (#363).

Acceptance

  • simple-codegen/simple-codegen-roaster compile with zero *Builder* types and zero builder references.
  • SPI boundary remains generateClass(GenerationTargetClassDto, SourceFormatter).
  • Generated output byte-identical; all tests green.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions