Skip to content

Autodetect: extract building an import layout from a block sequence - #10230

Merged
timtebeek merged 1 commit into
mainfrom
tim/autodetect-extract-layout-builder
Dec 1, 2026
Merged

timtebeek merged 1 commit into
mainfrom
tim/autodetect-extract-layout-builder

Conversation

@timtebeek

Copy link
Copy Markdown
Member

First step in splitting #10217 into smaller PRs. That PR has Autodetect vote on the import layout and fixes a few bugs in how a layout is built from a block sequence. Each of those steps needs the layout builder as a method it can call with a given block sequence and static-import and java/javax placement, instead of a lambda over the repository-wide values.

This moves the lambda body in ImportLayoutStatistics.getImportLayoutStyle() into layoutFrom(blocks, staticAtBot, javaxBeforeJava), called with isStaticImportsAtBot() and isJavaxBeforeJava(), so behavior is unchanged. The diff is mostly re-indentation; git diff -w shows only the new method signature and the parameters replacing the two method calls.

Verified locally: AutodetectTest, the Java style, format, OrderImports, AddImport and RemoveImport tests, and the Kotlin and Groovy AutodetectTest pass.

Move the lambda that turns the chosen block sequence into an ImportLayoutStyle
into a method that takes the static-import and java/javax placement as
parameters. No behavior change.
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Dec 1, 2026
@timtebeek
timtebeek enabled auto-merge (squash) December 1, 2026 19:52
@timtebeek
timtebeek merged commit 4778e02 into main Dec 1, 2026
1 check passed
@timtebeek
timtebeek deleted the tim/autodetect-extract-layout-builder branch December 1, 2026 20:05
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant