Bug 51659

Summary: New Code Formatter: minor problem with "White spaces/Array Initializers" option
Product: [Eclipse Project] JDT Reporter: Frederic Fusier <frederic_fusier>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: minor    
Priority: P3    
Version: 3.0   
Target Milestone: 3.0 M7   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Frederic Fusier CLA 2004-02-11 11:19:35 EST
It seems that something is wrong with space 'after opening brace', 'before 
closing brace' and 'between empty braces'.

Here's the initial test case I wrote:
public class Bug49361 {
    public static void main(String [ ] args) {
        int[] table = new int [] {1,2,3};
        int[] empty = new int [] {};
    }
}
which is the same than with the three options unset.

1) Format with (fix of the bug 49361):
'after opening brace'  = OFF
'before closing brace' = OFF
'between empty braces' = ON
I got one changed line:
       int[] empty = new int[] { };
=> OK

2) Format with:
'after opening brace'  = OFF
'before closing brace' = ON
'between empty braces' = OFF
I got two changed lines:
        int[] table = new int[] {1,2,3 };
        int[] empty = new int[] { };
=> OK?

3) Format with:
'after opening brace'  = ON
'before closing brace' = OFF
'between empty braces' = OFF
I got only one changed line:
        int[] table = new int[] { 1,2,3};
=> KO?

If we consider that 2nd format is correct, then I would expect for the 3rd one:
        int[] empty = new int[] { };
instead of:
        int[] empty = new int[] {};

The other possibility is that 2nd format was incorrect and should have produced:
        int[] empty = new int[] {};
instead of:
        int[] empty = new int[] { };
Then 3rd one would be correct...

At least it seems that there's some inconsistency here, isn't there?
Comment 1 Olivier Thomann CLA 2004-02-11 11:27:30 EST
This is trivial to fix.
Comment 2 Olivier Thomann CLA 2004-02-11 11:36:01 EST
The second case is incorrect. The empty array initializer should not have a
whitespace. The third case is correct.
Comment 3 Olivier Thomann CLA 2004-02-11 12:28:45 EST
Fix is ready.
Regression tests added.
Comment 4 Olivier Thomann CLA 2004-02-11 13:08:51 EST
Fixed and released in HEAD.
Regression tests added.
Comment 5 Olivier Thomann CLA 2004-02-12 15:35:08 EST
Verified in 200402121200.