Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 459304 - Improve line breaking when formatting ternary operators
Summary: Improve line breaking when formatting ternary operators
Status: RESOLVED DUPLICATE of bug 303519
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.4   Edit
Hardware: All All
: P3 minor (vote)
Target Milestone: 4.5 M6   Edit
Assignee: Mateusz Matela CLA
QA Contact: Manoj N Palat CLA
URL:
Whiteboard: To be verified for 4.6 M6
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-06 06:43 EST by Roland Illig CLA
Modified: 2016-02-17 17:43 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 Roland Illig CLA 2015-02-06 06:43:11 EST

    
Comment 1 Roland Illig CLA 2015-02-06 06:48:46 EST
When I have this ternary operator …

    public String toString(boolean b) {
      return b
        ? "true"
        : "false";
    }

… the formatter converts it to …

    public String toString(boolean b) {
      return b ? "true" : "false";
    }

When I want to keep the line breaks, I can insert empty comments at the end of the line.

    public String toString(boolean b) {
      return b //
        ? "true" //
        : "false";
    }

The formatter converts this to:

    public String toString(boolean b) {
      return b //
      ? "true" //
          : "false";
    }

The question mark and the colon should be aligned in the same column.
Comment 2 Jay Arthanareeswaran CLA 2015-02-10 02:02:10 EST
Thanks for the report, but we are not going to have the time to look at this any time soon. If anyone is willing to provide a patch, we can take a look at.
Comment 3 Mateusz Matela CLA 2016-02-17 17:43:06 EST
This problem no longer occurs after the formatter redesign.

*** This bug has been marked as a duplicate of bug 303519 ***