문제

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.

도움이 되었습니까?

해결책 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.

다른 팁

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

enter image description here

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top