Skip to content

Find builders anchored inside the referenced type #317

Description

@igel-devin-ai

Part of #301.

Current state

The resolver only looks up a candidate builder class next to the referenced type (<Simple><builderUsageSuffix> in the same package). A builder that lives inside the referenced type itself — e.g. the common Lombok/Immutables pattern public static PersonBuilder builder() on Person — is never discovered, even though generated code could call it the same way MapStruct does.

Goal

Extend the builder search with a second candidate location, MapStruct DefaultBuilderProvider-style:

  1. Look for an accessible static parameterless method on the referenced type (conventionally builder(), possibly a configurable name) returning a type that satisfies the builder contract.
  2. Verify that returned type against the same capability checks as the same-package candidate (empty/prefilled instantiation, build()).
  3. Decide precedence when both candidates exist (e.g. in-type builder() vs same-package XBuilder) — and whether an ambiguous in-type candidate (several matching methods) warns and skips like MapStruct.

Notes

  • Keeps the contract checks from the sibling sub-tasks unchanged — only the lookup gains a second location.
  • Worth deciding whether java.*/javax.* types are excluded from this lookup (MapStruct excludes them).

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