Bug 52747 - formatter - please special case empty array init
Summary: formatter - please special case empty array init
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 3.0 M9   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-02-21 17:03 EST by paul moore CLA
Modified: 2004-05-18 10:50 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description paul moore CLA 2004-02-21 17:03:08 EST
3m7.

Foo [] foo = new Foo []{};
is such a common idiom that it deserves special treatment. Either dont treat it 
as an array or have a special settings for it.

Also almost as commmon is
Foo [] foo = new Foo[]{bar};
Comment 1 Olivier Thomann CLA 2004-02-22 15:33:22 EST
What is the problem with the current options?
Comment 2 paul moore CLA 2004-02-22 16:31:12 EST
Maybe I am being over fussy. The thing that triggered the request was having 
this line

Object result = (foo == null)? new Object[]{} : foo.toArray();
changed to

Object result = (foo == null)? new Object[]
{} : foo.toArray();
To me that looked pretty wierd


I want to treat the empty array init as a special case

So I want this to be untouched (or forced)

Foo [] foos = new Foo[]
{
   new Foo(x),
   new Foo(y),
}

But I also want this to happen
Object res = new Object[]{};
not
Object res = new Object[]
{
}


Comment 3 Olivier Thomann CLA 2004-04-19 16:57:36 EDT
The option FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE has been added.
It is false by default to preserve existing behavior.
Regression tests added.
Fixed and released in HEAD.
Comment 4 David Audel CLA 2004-05-18 10:50:17 EDT
Verified for 3.0M9