Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Java source code formatter does not wrap lines at inner expressions (or settings dialog broken?)
Java source code formatter does not wrap lines at inner expressions (or settings dialog broken?) [message #884641] Mon, 11 June 2012 14:40
Marco Kaufmann is currently offline Marco KaufmannFriend
Messages: 1
Registered: June 2012
Junior Member
I'm not sure whether this really is a bug or if there is any deeper reason for this, so I'm consulting the forum first. This is my Problem:

I have an expression that is nested as follows:

boolean x = a && ((b && (c == d)) || (e && (f == g)));


It seems that the source code formatter only considers the very outer nesting level of that expression and does not wrap the inner expressions.

If this is what the checkbox "Prefer wrapping outer expressions (keep inner expressions on line)" in the settings dialog is intended for, then this checkbox doesn't work because it doesn't change this behavior.

Assume this expression:

1: boolean x = aaaaaaaaaaaaaaaa && ((bbbbbbbbbbbbbbbb && (cccccccccccccccc == dddddddddddddddd)) || (eeeeeeeeeeeeeeee && (ffffffffffffffff == gggggggggggggggg)));


then these two lines are what the formatter produces:

1: boolean x = aaaaaaaaaaaaaaaa && 
2:     ((bbbbbbbbbbbbbbbb && (cccccccccccccccc == dddddddddddddddd)) || (eeeeeeeeeeeeeeee && (ffffffffffffffff == gggggggggggggggg)))


although the second part of the very outer binary expression is still too long to fit one line. I would expect that line 2 is wrapped at the next inner binary operator again, which is ||. Then, this is the result that I would expect and how I also would do it when formatting it by hand:

1: boolean x = aaaaaaaaaaaaaaaa && 
2:     ((bbbbbbbbbbbbbbbb && (cccccccccccccccc == dddddddddddddddd)) ||
3:         (eeeeeeeeeeeeeeee && (ffffffffffffffff == gggggggggggggggg)));


My settings are:

  • Prefer wrapping outer expressions: enabled
  • Maximum line width: 80
  • Assignments: Do not wrap
  • Binary Expression: Wrap where necessary


When I disable "Prefer wrapping outer expressions", the result is still the same.

[Updated on: Mon, 11 June 2012 14:43]

Report message to a moderator

Previous Topic:Eclipse skipping breakpoints
Next Topic:Splash screen freeze
Goto Forum:
  


Current Time: Sat Apr 27 02:19:00 GMT 2024

Powered by FUDForum. Page generated in 0.02118 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top