Community
Participate
Working Groups
package object_in; public enum TestEnumRead { TEST; public String field; public void foo() { String s = field; } } formatting it produces package object_in; public enum TestEnumRead { TEST ; public String field; public void foo() { String s = field; } }
And?
Do you expect the semi-colon to remain on the same line than the 'TEST' ? This would be ok, when you have only one or two constants, but when you have few constants with bodies, you easily miss the semi-colon if it is not moved on the next line. It tried to see how to do this through options, but I could not see an obvious pattern. There are no java conventions for formatting the new 1.5 constructs. So any suggestions are welcome as long as we can infer options out of them.
Yes, I would expect having the semicolon on the same line as TEST. For me its like a field declaration where I declare more than one field (e.g. String A, B, C;)
This is fine when you don't have a body, but once you have a body and a few constants, it is easy to miss the semicolon.
I consider anonymous enums a rare scenario. In this case I would expect the following formatting enum E { A { void foo() { } }, B { void foo() { } }; }
Ok, I will change it to keep the semi-colon after the last constant. We might want to revisit that in the future depending how this is accepted.
Fixed and released in HEAD. Regression tests added and existing tests updated. The rule is the following: - the semi-colon is left behind the last constant (it is not on a new line). - if enum constants have a body, the next constant is moved to the next line for clarity. Hope this is the expected behavior.
Verified for 3.1 M4 using build I200412142000.