Community
Participate
Working Groups
I have the following code in my class: private boolean shouldStop() { synchronized (s_monitor) { return ((s_fatalFailures > s_fatalFailureLimit) || ((s_nonFatalFailureLimit > 0) && (s_nonFatalFailures > s_nonFatalFailureLimit))); } } The variables s_fatalFailures, s_fatalFailureLimit, s_nonFatalFailures, and s_nonFatalFailureLimit are all ints. The return statement, unformatted, is 145 characters long. I am using Eclipse 3.0.2. I have set up my code formatter to allow for a line width of 80 characters, and I have experimented with various settings on the Binary Expressions Line Wrapping page, and there doesn't seem to be a setting where Eclipse will recognize that my "return" statement is too long. Eclipse doesn't seem to want to break this line anywhere so that it wraps to fit logically within the 80-character limit. Even if I manually format the line the way I want, if I subsequently use the Ctrl-Shift-F option to format, Eclipse reverts the return statement to a single line that is 145 characters long.
I have the same problem with various types of statements. Here's an example that Eclipse will not wrap (i.e. it puts everything on one line) regardless of my settings (even using the Java Conventions and Eclipse 2.1 built-in profiles): if (!((reqPkt instanceof RdWrSizedPacket && ((RdWrSizedPacket) reqPkt).compat == Bit.ONE) || (reqPkt instanceof AtomicRMWPacket && ((AtomicRMWPacket) reqPkt).compat == Bit.ONE))) { } In my particular file, this line is also indented 24 spaces, making the total line length 202. It should wrap at 80. This bug is similar to bug 76633.
Oh, and I'm running I20050331-1200.
Deferring post 3.1
Reopening.
The problem comes from the surrounding parenthesized expression. I am investigating.
*** Bug 115210 has been marked as a duplicate of this bug. ***
Are there any news concerning this bug? As I've already written in the description of 93433: "This is rather annoying, because the code gets "QAed" with Checkstyle, which always reports that the line is too long once I use the code formatting. :-(" I would be VERY glad if this bug was fixed. Thanks in advance!
This will be done if we find some time to do it. Patches are always welcome.
I can't promise, but I'll try to look into this. Could you point me to the rough direction, code-wise? Thanks! Cheers, Dennis
You can look at the formatting of binary expression in this class: org.eclipse.jdt.internal.formatter.CodeFormatterVisitor Or even better in this class: org.eclipse.jdt.internal.formatter.CodeFormatterVisitor2 The second one is used to format DOM/AST nodes. This is where we want to go for the future.
Ownership has changed for the formatter, but I surely will not have enough time to fix your bug during the 3.5 development process, hence set its priority to P5. Please provide a patch if you definitely need the bug to be fixed in this version and I'll have a look at it... TIA
This problem no longer occurs after the formatter redesign. *** This bug has been marked as a duplicate of bug 303519 ***