Skip to content

Update Reformatter to honour case wrap settings with switch expressions (GH7326).#9484

Open
neilcsmith-net wants to merge 2 commits into
apache:masterfrom
neilcsmith-net:gh7326
Open

Update Reformatter to honour case wrap settings with switch expressions (GH7326).#9484
neilcsmith-net wants to merge 2 commits into
apache:masterfrom
neilcsmith-net:gh7326

Conversation

@neilcsmith-net

Copy link
Copy Markdown
Member

Update Reformatter to only add a newline to cases in switch expressions when wrapCaseStatements is set to WRAP_ALWAYS (default).

Fixes #7326

Alternative might be to ignore the force wrap setting when we have an ARROW rather than COLON. I'm not sure the default works as well in those cases.

@neilcsmith-net neilcsmith-net requested a review from mbien July 3, 2026 09:36
@neilcsmith-net neilcsmith-net added the Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) label Jul 3, 2026
@neilcsmith-net neilcsmith-net added this to the NB31 milestone Jul 3, 2026

@mbien mbien left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even though this might be incomplete, its a good change since this makes the NEVER option usable (which is nice for arrow switches since it still wraps blocks correctly, see snippet I posted via comment).

We could consider changing the default to NEVER but this would probably require to update many tests.

Update Reformatter to only add a newline to cases in switch expressions
when wrapCaseStatements is set to WRAP_ALWAYS (default).

Fixes apache#7326
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Formatting Issue - Wrapping for Java 21 Style Switch Cases that have Arrows

2 participants