Bug 336908 - [formatter] Java Formatter does not wrap long enum constant declarations
Summary: [formatter] Java Formatter does not wrap long enum constant declarations
Status: VERIFIED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.6.1   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: 3.7 M6   Edit
Assignee: Ayushman Jain CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-11 04:31 EST by David Balažic CLA
Modified: 2011-03-07 11:09 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Balažic CLA 2011-02-11 04:31:18 EST
Long enum lines are not split to fit inside max line lenght limit.
Tried both Eclipse [built-in]  and Java Conventions [built-in] formatters.

Example:
	public enum Foo {
		BAR, FOOBAR, BAZBAR, FOOBAZ, FOOBARBAZ, BARBAZFOO, BARFOOBAZ, BARFOOBAR, FOOBARFOO, BAZFOOBAZ, FOOBARFOOBAZ, FOOOO
	}

array initializers and function parameters that are similar to enum constant lists are wrapped, so why are enums not?

-- Configuration Details --
Product: Eclipse 1.3.1.20100913-1228 (org.eclipse.epp.package.jee.product)
Installed Features:
 org.eclipse.jdt 3.6.1.r361_v20100714-0800-7z8XFUSFLFlmgLc5z-Bvrt8-HVkH
Comment 1 David Balažic CLA 2011-02-11 04:32:36 EST
Note: the above example should be having 3 lines:
1: public enum Foo {
2:   the values listed
3: }
Comment 2 Ayushman Jain CLA 2011-02-11 06:42:08 EST
Line wrapping in enum declarations can be achieved by the Line wrapping tab in Formatter preferences> select 'enum declarations', and at the bottom in "Line wrapping policy" drop down menu, chose 'Wrap where necessary'.

Note that both inbuilt formatter settings you used dont have this on by default. So you'll have to create a new formatter profile and switch it on.
Comment 3 Ayushman Jain CLA 2011-02-14 00:56:41 EST
Closing as WORKSFORME
Comment 4 David Balažic CLA 2011-02-14 01:46:40 EST
Sorry, the question is : why is the default set like it is. What is the reasoning?
Why are for example array initializers wrapped, but enums not?
Comment 5 Olivier Thomann CLA 2011-02-16 10:13:48 EST
The default settings won't change. They might not have been well defined initially, but changing them would cause changes to formatted code for users that are using the default settings.
What you want can be achieved by changing the default formatter profile.
Closing as WORKSFORME.
Comment 6 Olivier Thomann CLA 2011-03-07 11:09:00 EST
Verified for 3.7M6.