Bug 250753

Summary: [formatter] Insert space between empty braces in array initializers ignored without "Keep empty array initializer on one line"
Product: [Eclipse Project] JDT Reporter: Matt Whitlock <eclipse>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P5 CC: frederic_fusier
Version: 3.4.1Keywords: helpwanted
Target Milestone: 3.5 M3   
Hardware: Other   
OS: Linux   
Whiteboard:

Description Matt Whitlock CLA 2008-10-14 06:53:12 EDT
Build ID: M20080911-1700

Steps To Reproduce:
If "Keep empty array initializer on one line" is checked, then "Insert space" "between empty braces" in "array initializers" works as expected.  However, if "Keep empty array initializer on one line" is not checked, the space is never inserted.  This is true even if "Brace positions" for "Array initializer" is set to "Same line", which grays out the "Keep empty array initializer on one line" check box.  (Toggling the "Keep empty array initializer on one line" check box requires first changing the "Array initializer" setting to "Next line", then toggling the check box, then changing back to "Same line".)


Array initializer: Same line
Keep empty array initializer on one line: no
White Space, Array initializers, between empty braces: yes

Preview:
int[] array0 = new int[] {};
int[] array1 = new int[] { 1, 2, 3 };
int[] array2 = new int[3];


Array initializer: Same line
Keep empty array initializer on one line: yes
White Space, Array initializers, between empty braces: yes

Preview:
int[] array0 = new int[] { };
int[] array1 = new int[] { 1, 2, 3 };
int[] array2 = new int[3];


Expected results:
The first preview should look identical to the second preview, since the "Keep empty array initializer on one line" option should have no bearing if "Array initializer" is set to "Same line".
Comment 1 Frederic Fusier CLA 2008-10-14 07:52:52 EDT
Unfortunately, I surely will not have enough time to fix your bug during the 3.5 development process, hence set its priority to P5.
Please provide a patch if you definitely need the bug to be fixed in this
version and I'll have a look at it...
TIA
Comment 2 Olivier Thomann CLA 2008-10-14 12:26:11 EDT
Fix is trivial.
Released for 3.5M3.
Added regression test org.eclipse.jdt.core.tests.formatter.FormatterRegressionTests#test719
Comment 3 Frederic Fusier CLA 2008-10-28 06:48:13 EDT
Verified for 3.5M3 using I20081026-2000.