Skip to content

Keep the indentation of declarations FinalizeLocalVariables and MoveFieldAnnotationToType edit in place - #1276

Merged
jkschneider merged 1 commit into
mainfrom
keep-declaration-indentation
Nov 20, 2026
Merged

jkschneider merged 1 commit into
mainfrom
keep-declaration-indentation

Conversation

@jkschneider

Copy link
Copy Markdown
Member

FinalizeLocalVariables and MoveFieldAnnotationToType formatted the declaration they change with autoFormat, which gives the declaration's line the indentation of a file formatted from scratch. In a file indented by hand, or with tabs among spaces, that moves a line the recipe only edited. maybeAutoFormat formats the same way, and with openrewrite/rewrite#10089 it keeps the indentation of the line where a declaration it changes stays. Until that is released, the output is unchanged.

Found by running the tests of FinalizeLocalVariables and MoveFieldAnnotationToType with one more space at the start of each indented line that opens nothing, the opt-in shifted-input mode of openrewrite/rewrite#10090. With openrewrite/rewrite#10089 the mode flagged 10 of those tests (7 of FinalizeLocalVariables, 3 of MoveFieldAnnotationToType) before this change and none after. The tests pass with the published rewrite snapshot and with both of those changes.

…ieldAnnotationToType edit in place

`FinalizeLocalVariables` and `MoveFieldAnnotationToType` formatted the declaration they change with
`autoFormat`, which gives the declaration's line the indentation of a file formatted from scratch.
In a file indented by hand, or with tabs among spaces, that moves a line the recipe only edited.
`maybeAutoFormat` formats the same way, and with openrewrite/rewrite#10089 it keeps the indentation
of the line where a declaration it changes stays. Until that is released, the output is unchanged.

Found by running the tests of `FinalizeLocalVariables` and `MoveFieldAnnotationToType` with one
more space at the start of each indented line that opens nothing, the opt-in shifted-input mode of
openrewrite/rewrite#10090. With openrewrite/rewrite#10089 the mode flagged 10 of those tests (7 of
`FinalizeLocalVariables`, 3 of `MoveFieldAnnotationToType`) before this change and none after. The
tests pass with the published rewrite snapshot and with both of those changes.
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Nov 20, 2026
@jkschneider
jkschneider merged commit 593cbe9 into main Nov 20, 2026
1 check passed
@jkschneider
jkschneider deleted the keep-declaration-indentation branch November 20, 2026 13:34
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant