Bug 208451 - [formatter] Java code style formatter option "do not wrap" DOES unwrapping lines
Summary: [formatter] Java code style formatter option "do not wrap" DOES unwrapping lines
Status: VERIFIED DUPLICATE of bug 198074
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 critical (vote)
Target Milestone: 3.5 M4   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-01 12:55 EDT by Reinhold Fuereder CLA
Modified: 2008-12-09 14:03 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 Reinhold Fuereder CLA 2007-11-01 12:55:02 EDT
Build ID: I20070621-1340

Steps To Reproduce:

public class MyTest {

    @Test
    public void testname() throws Exception {
        int i = 5, j = 6, k = 7;
        if (new String().length() != 0 &&
                (i < j && j < k)) {

        }
    }
}

Auto-format with all Java code style formatter line wrapping options set to "do not wrap" (maximum line width is for this example set to 50) leads to:

public class MyTest {

    @Test
    public void testname() throws Exception {
        int i = 5, j = 6, k = 7;
        if (new String().length() != 0 && (i < j && j < k)) {

        }
    }
}


More information:
Setting all Java code style formatter line wrapping options to "do not wrap" unwraps lines. This is especially annoying in cases where e.g. (a) a slightly more complex if condition is made up of several expressions and the developer has added explicit hard line breaks on purpose to increase readability; or (b) longer strings (e.g. for logging) are assembled  from static strings and variables and again the initial developer's choice has hard line breaks on purpose in order to be more readable. As a result the Java source code auto format cannot be applied, solely due to this single issue leading to less readability in certain cases.

See also D.B.'s comment at http://www.jroller.com/robwilliams/entry/couple_of_eclipse_shortcuts#comments and http://dev.eclipse.org/newslists/news.eclipse.platform/msg67607.html

Changing/fixing the "do not wrap" option to really keep the original wrapping would allow applying auto formatting at long last, while not endangering any third-party auto-formating tools vendor, because the typically hopefully offer additional advanced features anyhow ;-)
Comment 1 Jerome Lanneluc CLA 2007-11-02 06:45:51 EDT
Why is this critical?
Comment 2 Reinhold Fuereder CLA 2007-11-05 02:41:02 EST
Of course this is subjective, but as I tried to convey this is critical (for us and -- intentionally exaggerated -- probably for most projects), because the auto-formating's line unwrapping decreases the readability of the code and therefore auto-formatting can not be utilized.

(Longer maximum line width are more and more the norm, so explicit earlier line breaks are getting more important with respect to allowing better readability.)
Comment 3 Creo Ilbe CLA 2007-11-05 07:53:00 EST
See and vote for Bug 198074
Comment 4 Reinhold Fuereder CLA 2007-11-05 08:10:34 EST
Thanks, Creo Ilbe, if I am not mistaken than Bug 198074 is exactly what we'd like too. I have voted for it and marked this issue as a duplicate.


*** This bug has been marked as a duplicate of bug 198074 ***
Comment 5 Frederic Fusier CLA 2008-12-03 07:22:14 EST
Reopen to assign...
Comment 6 Frederic Fusier CLA 2008-12-03 07:22:45 EST

*** This bug has been marked as a duplicate of bug 198074 ***
Comment 7 Kent Johnson CLA 2008-12-09 14:03:40 EST
Verified for 3.5M4 using I20081209-0100