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