Bug 84238

Summary: [1.5] EnumDeclaration.ENUM_CONSTANTS_PROPERTY incorrectly rewritten
Product: [Eclipse Project] JDT Reporter: Alexander Pavlov <Alexander.Pavlov>
Component: CoreAssignee: Martin Aeschlimann <martinae>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Alexander Pavlov CLA 2005-02-02 11:15:28 EST
(3.1M4)
We have the following enum type:

public enum MyEnum {
}

Running the following code for this type,

EnumDeclaration enumDecl = ... ;
String name = "VALUE1";
EnumConstantDeclaration ecd = enumDecl.getAST().newEnumConstantDeclaration();
ecd.setName(ecd.getAST().newSimpleName(name));
ListRewrite lrw = rw.getListRewrite(enumDecl, 
EnumDeclaration.ENUM_CONSTANTS_PROPERTY);
lrw.insertFirst(ecd, null); // actually, any insert... method

and further rewriting the source code, we get the following result:

public enum MyEnumVALUE1 {
}

which is different from the correct result. The rewriting is performed properly 
if there are one or more enum constants already present in the list.
Comment 1 Martin Aeschlimann CLA 2005-02-02 13:04:28 EST
fixed > 20050202
Comment 2 Martin Aeschlimann CLA 2005-02-02 13:04:51 EST
fix released
Comment 3 David Audel CLA 2005-02-15 12:27:18 EST
Verified in I20050214-0927