Bug 51659 - New Code Formatter: minor problem with "White spaces/Array Initializers" option
Summary: New Code Formatter: minor problem with "White spaces/Array Initializers" option
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 2000
: P3 minor (vote)
Target Milestone: 3.0 M7   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-02-11 11:19 EST by Frederic Fusier CLA
Modified: 2004-02-12 15:35 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.