Community
Participate
Working Groups
The formatter doesn't do a good job on formatting array expressions. Instead of static String[] names = { "Afk kdhf ", "b fhs sf jhfgd", ... }; I'd prefer static String[] names = { "ahsjahsa", .... }; with just one indent (not two as the formatter does) and the { in the same line as the = and the } dedented again. For people who prefer the style while () { .... } the { might be placed differently, but never as the formatter does now. If you add even more strings to the array, the formatter uses static String[] names = { "Afk kdhf ", "b fhs sf jhfgd", "ceh gfskg fgfds", "hhfkdshk", "fhfjkdhlkfdl", "hhfkdshk", "fhfjkdhlkfdl" }; which should be static String[] names = { "fjdsfjl", .... }; Here's a more complex expression (long strings skipped): protected static IPropertyDescriptor[] descriptors = { new PropertyDescriptor( ID_SIZE, OdinMessages.getString("...")), new PropertyDescriptor( ID_LOCATION, OdinMessages.getString("..."))}; This again should IMHO be protected static IPropertyDescriptor[] descriptors = { new ...., new .... }; Basically, the open { should stay in the line before, the content should be indented by one not two levels and the } should be in at the same level than the expression itself.
Will reconsider post 2.0.
Resurrecting formatter issues in 2.1 stream.
Clearing resolution
It gets even worse with two dimensional arrays: private static final Object[][] testData = { { "3/4/2002", "Foo"}, { "2/4/2002", "Bar" }, { "1/4/2002", "Qux" } }; Yuk! My preference is for: private static final Object[][] testData = { { "3/4/2002", "Foo" }, { "2/4/2002", "Bar" }, { "1/4/2002", "Qux" } };
We are investigating a brand new formatter to fix that kind of defects. Be sure that we will have tests to cover this area.
*** Bug 24428 has been marked as a duplicate of this bug. ***
We need to clear 2.1 bug reports that won't be addressed before 2.1. The new implementation is still in the works. Therefore we cannot include it for 2.1. Not enough testing and we need to polish the preferences. This will be address for 2.2 as stated in the JDT/Core plan.
Resurrecting for 3.0
Reopen for 3.0 consideration.
This is improved with the new code formatter. Please reopen if the changes are not good enough. Fixed and released in HEAD.
Verified.
I just tried the 2nd example with 3.0M4 and now, it emits static String[] names = {"Afk kdhf ", "b fhs sf jhfgd", ... "fhfjkdhlkfdl", "hhfkdshk", "fhfjkdhlkfdl"}; It looks like it tries to fill the lines and will continue the elements in the next line, indented with 2 tabs. I'd still prefer this: static string[] names = { <1tab>"hkjfshdjkfd", ... }; but the new formatter is definitely an improvement. Unfortunately, the formatter still doesn't honor the "insert a new line before an opening brace" setting for these kind of array literals (or it's just a problem related to the non-yet-implemented options page).
I will open a new bug report for that. See bug 44813. I open bug 44815 for the size of the continuation indent.