Eclipse Java formatter for array initializers
Is there a way to format array initializers like
// 1: If they exceed my maximum line width, all on new line except the first one
public static final String[] MY_ENUM_STRINGS = {"abcdefg123",
"abcdefgh",
"abcdefghi",
"abcdefghij",
"abcdefghijk"};
// 2: If they fit in one line, all in one line
public static final Integer[] MY_ENUM_NUMBERS = {1, 2, 3, 4, 5};
I thought I found the solution under Line Wrapping > Wrapping settings > Other expressions > Array initializers
set to Wrap all elements, except first element if not necessary
. But if I am slightly above the maximum line width, I get
public static final Integer[] MY_ENUM_NUMBERS_BAD =
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
The above example is reproducable with maximum line width 70.
Read more here: Source link