Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 253993 - [formatter] JDT Java Code formatter gets line indent wrong for long declarations
Summary: [formatter] JDT Java Code formatter gets line indent wrong for long declarations
Status: VERIFIED DUPLICATE of bug 303519
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4.1   Edit
Hardware: PC Windows Vista
: P3 normal (vote)
Target Milestone: 4.13 M1   Edit
Assignee: Mateusz Matela CLA
QA Contact:
URL:
Whiteboard: To be verified for 4.13 M1
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-05 17:15 EST by Pete H CLA
Modified: 2019-07-10 00:53 EDT (History)
5 users (show)

See Also:


Attachments
Export of the Eclipse "formatter" configuration. (28.08 KB, application/xml)
2008-11-05 17:15 EST, Pete H CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Pete H CLA 2008-11-05 17:15:05 EST
Created attachment 117148 [details]
Export of the Eclipse "formatter" configuration.

Build ID: M20080911-1700

Steps To Reproduce:
My code is configured to auto format on save (will attach the formatting XML).

The following line should wrap "indent by one" "only when necessary" according to my settings, which if I understand right will make it wrap to column 4 if the "private" starts on column 0.

private static final String m_rLnF  =                                         "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel";

It doesn't, and wraps with the literal string to a location starting in column 41, which I think is a bug. I could be misunderstanding the tool, in which case, my apologies ;)


More information:

Half the point of making it wrap is to avoid overspilling the "maximum of 80 chars" line limitation in our coding standard, there seems no way to make it wrap earlier in the line than the '=' which means that long declarations given Java's verbose "private static final <type>" semantics often overflow 80 characters.
Comment 1 Pete H CLA 2008-11-05 17:24:41 EST
Just a note that I have rechecked and none of the existing autoformatter options let you shift the value of the declaration back before the '='.

My workaround currently is to break up long string literals using "a" + "b" syntax and split the sub-components over multiple lines. For long numbers I don't have a good solution other than deleting the less functional specifiers like "private" and "final".

(I can't commit to our SVN with any line over 80 characters, a commit hook rejects the file, and my boss insists we use the autoformatter =P)

If this isn't a defect, can this get converted to an enhancement request to allow a new ["wrap when necessary", "indent by one"] option which means align the code to one column indented from the start of the type specifier list.

Cheers, 

P
Comment 2 Eclipse Genie CLA 2019-05-02 13:17:44 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.
Comment 3 Mateusz Matela CLA 2019-06-10 18:14:25 EDT
The problem was related to the "align fields in columns" setting.

It no longer occurs after the formatter redesign (probably).

*** This bug has been marked as a duplicate of bug 303519 ***
Comment 4 Manoj N Palat CLA 2019-07-10 00:53:43 EDT
Verified for Eclipse 4.13 M1 with Build id: I20190709-1800