Question

IntelliJ's reformat code option (ctrl+alt+l) adds an extra lines to enum declarations. It will change this:

public enum Day {MON, TUE, FRI};

to this:

public enum Day {MON, TUE, FRI}

;

How do I change the behavior of the reformat to not add the extra white space? I was not able to find enums in the Code style settings (File -> Settings -> Code Styles -> Java).

Update: It turns out that IntelliJ is treating the enum and the semicolon as two separate statements, which apparently they are because the semicolon is not required for enum declaration. IntelliJ is adding a blank line after a class declaration (enum) and then showing the semicolon. Removing the semicolon solves my problem.

Was it helpful?

Solution 2

Doesn't it also give you a warning saying that semicolon is unnecessary? It does for me. If you remove the semicolon is that a solution to your problem? It won't create unnecessary whitespace that way.

OTHER TIPS

Find a tab called Code Style -> java -> 'Wrapping and Braces' . In the list there is latest element called 'Enum constants'

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top