Bug 329709

Summary: [formatter] Formatter fails to format enum with extra semicolon and body
Product: [Eclipse Project] JDT Reporter: Brian Atkinson <nairb774>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jarthana, Olivier_Thomann
Version: 3.7   
Target Milestone: 3.7 M4   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Proposed fix + regression tests none

Description Brian Atkinson CLA 2010-11-08 16:06:27 EST
Build Identifier: 20100917-0705

When a enum has two semicolons after the list of enum values, and any body the formatter fails to format the whole file that contains the enum. No exceptions show up in the logs when the formatter fails to run.

Reproducible: Always

Steps to Reproduce:
The following examples fail to format (Java 5):

enum Fail1 {A;;{}}
enum Fail2 {A,B;;{}}
enum Fail3 {A;;public void foo() {}}
enum Fail4 {A;;public int i = 0;}

The following examples do format correctly:

enum Good1 {A;;}
enum Good2 {A,B;;}
enum Good3 {A;;/* blah */}
enum Good4 {A;{}}
enum Good5 {A;public void foo() {}}
enum Good6 {A;public int i = 0;}
Comment 1 Olivier Thomann CLA 2010-11-08 23:07:12 EST
I'll take a look.
Comment 2 Olivier Thomann CLA 2010-11-09 09:23:55 EST
Created attachment 182716 [details]
Proposed fix + regression tests

We need to check for semi-colons before the first member.
Comment 3 Olivier Thomann CLA 2010-11-09 09:25:27 EST
Released for 3.7M4.
Regression tests added in:
org.eclipse.jdt.core.tests.formatter.FormatterRegressionTests#test730
org.eclipse.jdt.core.tests.formatter.FormatterRegressionTests#test731
org.eclipse.jdt.core.tests.formatter.FormatterRegressionTests#test732
org.eclipse.jdt.core.tests.formatter.FormatterRegressionTests#test733
Comment 4 Jay Arthanareeswaran CLA 2010-12-07 06:38:14 EST
Verified for 3.7M4 using build I20101206-1800.