Bug 27249

Summary: incorrect formatting of empty array initialization blocks
Product: [Eclipse Project] JDT Reporter: neil_buesing
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: minor    
Priority: P3    
Version: 2.1   
Target Milestone: 3.0 M5   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

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.