Skip to content

java eclipse formatter: Avoid wrapping explicit line breaks as supported in all recent versions of eclipse. #443

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from

Conversation

ctvoigt
Copy link

@ctvoigt ctvoigt commented Mar 28, 2019

Preserve explicit line breaks for constants (with values) in enums and break them only if necessary.

Corresponding wording from java guide
4.5.1
The prime directive of line-wrapping is: prefer to break at a higher syntactic level.
4.5.1 Where to break; 4. A comma (,) stays attached to the token that precedes it.

Example

raw code
enum Example {CANCELLED, RUNNING, WAITING, FINISHED }enum Example {GREEN(0, 255, 0), RED(255, 0, 0) }

formatted

enum Example {
  CANCELLED, RUNNING, WAITING, FINISHED
}

raw code including explicit line breaks

enum Example {CANCELLED,
 RUNNING, WAITING, FINISHED }enum Example {GREEN(0, 255, 0), RED(255, 0, 0)  }

formatted

enum Example {
  CANCELLED,
  RUNNING, WAITING, FINISHED
}


enum Example {
  GREEN(0, 255, 0), RED(255, 0, 0)
}

Tested on environment

Spring Tool Suite 4
Version: 4.1.2.RELEASE
Build Id: 201902210640
OS: Windows 10, v.10.0, x86_64 / win32
Java version: 1.8.0_121

…ns of eclipse.

Enum: Preserve explicit line breaks for constants (with values) in enums and break them only if necessary.
@vapier vapier added lang:java The Java language and removed cla: yes labels Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang:java The Java language
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants