Bug 27249 - incorrect formatting of empty array initialization blocks
Summary: incorrect formatting of empty array initialization blocks
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P3 minor (vote)
Target Milestone: 3.0 M5   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-11-27 11:14 EST by neil_buesing CLA
Modified: 2003-11-20 12:00 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 neil_buesing CLA 2002-11-27 11:14:37 EST
If I run 'format' on the following java code:

package com.company.module;

public class X {
  public X() {
    Object[] objects = new Object[] {};
  }
}

I get:

package com.company.module;

public class X {
  public X() {
    Object[] objects = new Object[] {
    };
  }
}

However, if I do it on the following code:

public class X {
  public X() {
    Object[] objects = new Object[] {"x", "y"};
  }
}

no change occurs (the ending bracket stays put).

And if I do it for:

public class X {
  public X() {
    Object[] objects = new Object[] {"x", "y"
    };
  }
}

I get the bracket put back up as in the following:

public class X {
  public X() {
    Object[] objects = new Object[] {"x", "y"};
  }
}

I'm using the 11/19/2002 Eclipse 2.1 integration build.

My code formatter settings are:

----from preference dialog----
{

  if (size < currentSize) {
    try {
      size = inStream.available();
    } catch (IOException e) {
    }
  } else if (size == currentSize) {
    ++size;
  } else {
    --size;
  }

}
----end----

I believe based on style guidelines the right bracket should stay put even for 
the empty array senario, since it isn't denoting a block of code.
Comment 1 Olivier Thomann CLA 2003-01-15 13:23:16 EST
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.
Comment 2 Philipe Mulet CLA 2003-06-12 06:35:45 EDT
Resurrecting for 3.0
Comment 3 Philipe Mulet CLA 2003-10-30 04:34:00 EST
does it work now ?
Comment 4 Olivier Thomann CLA 2003-10-30 08:44:40 EST
Fixed. Regression test added.
Comment 5 David Audel CLA 2003-11-20 12:00:53 EST
Verified.