Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 165703

Summary: [ast rewrite] Enum constants are always separated by ", "
Product: [Eclipse Project] JDT Reporter: Dmitry Denisov <ddenisov>
Component: CoreAssignee: David Audel <david_audel>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: frederic_fusier, jerome_lanneluc, marcelop
Version: 3.3   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug
Bug Depends on: 184485    
Bug Blocks:    

Description Dmitry Denisov CLA 2006-11-23 14:26:03 EST
Newly added enum constants seem to be always separated by a comma with a following space.

For example, if I would like to add a constant with a Javadoc to an existing list of enum constants, I am getting the output like this:

enum E {
  /**
   * javadoc 1
   */
  ENUM_CONST_1, /**
   * javadoc 2
   */
  ENUM_CONST_2;
}

Would it be possible to use logic similar to adding body declarations? E.g. determine separating new lines based on either existing constants or, if they do not exist, use DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS?

The ", " string is hardcoded on line 3029 in ASTRewriteAnalyzer, method visit(EnumConstantDeclaration node). This value seems to be used later without modifications in the inner class ListRewriter...
Comment 1 Martin Aeschlimann CLA 2007-04-30 07:22:48 EDT
I have a fix ready, but I have troubles with formatting the enum constants: see bug 184485
Comment 2 Martin Aeschlimann CLA 2007-05-14 09:52:55 EDT
for 3.4 as this is more a presentation issue, no wrong code generated.
Comment 3 Jerome Lanneluc CLA 2008-05-07 07:28:17 EDT
Deferring post 3.4 as we ran out of time
Comment 4 Eclipse Genie CLA 2019-06-27 07:14:52 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.