Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 110569

Summary: [formatter] Code Formatting: Line Wrapping. Maximum line width problem with method declarations.
Product: [Eclipse Project] JDT Reporter: Geoff Gibbs <geoff>
Component: CoreAssignee: Mateusz Matela <mateusz.matela>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P5 CC: Andrzej.Miazga, ben.arnold.spam, fractalVisionz, j.c.yip, juergenkrey, julien.henry, krzysztof.daniel, mateusz.matela, tmoore, wigbam
Version: 3.1   
Target Milestone: 4.5   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Java source affected by this bug
none
Formatter settings for the previous attachment none

Description Geoff Gibbs CLA 2005-09-26 05:03:41 EDT
In the java code formatter, when specifying line wrapping options for Method
declarations, it seems that the final bracket is being ignored.

To test:
In the line wrapping tab of the code formatting "Edit Profile" dialog, set the
line width for preview window to 69.
Select "Method Declarations: Parameters"

The final bracket from the method declaration is beyond the 69 character limit.
Comment 1 Olivier Thomann CLA 2005-09-30 09:08:02 EDT
Right now the final bracket is not part of the wrapping mecanism.
Comment 2 Olivier Thomann CLA 2006-04-20 09:56:38 EDT
*** Bug 135519 has been marked as a duplicate of this bug. ***
Comment 3 Jason Yip CLA 2006-08-23 00:32:46 EDT
By "bracket", I'm assuming you mean brace?  At first I thought this was an off-by-one error since you can work around it by reducing your allowed line length by one.  This one is high on the annoying list for me.
Comment 4 Tim Moore CLA 2006-09-20 15:24:04 EDT
See also Bug 69585
Comment 5 Tim Moore CLA 2006-09-20 15:33:47 EDT
Created attachment 50589 [details]
Java source affected by this bug

Here's an example of Java source affected by this bug.  Note that on lines 49 & 50, the method parameter itself exceeds the maximum line length and is correctly wrapped, but line 58 is not wrapped despite exceeding the maximum line length with the space and { at the end of the line.  Note that in this situation, I wouldn't want the { to be wrapped by itself, but rather I would want it to break at column 41 and wrap the method parameter onto the next line as with lines 49 & 50.
Comment 6 Tim Moore CLA 2006-09-20 16:36:42 EDT
Created attachment 50594 [details]
Formatter settings for the previous attachment
Comment 7 Jamie Meyers CLA 2007-05-30 19:16:08 EDT
I don't know if this bug was ever solved, but it has resurfaced in 3.2.2 [build M20070212-1330].

Here is my example. I have the line wrap set at 115. And here is the output:

<TAB>public ItemModel(String name, String description, double length, double width, double height, double strength) {

However, the output should be:
<TAB>public ItemModel(String name, String description, double length, double width, double height, 
<TAB><TAB>double strength) {

Comment 8 Frederic Fusier CLA 2008-08-19 10:30:08 EDT
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
Comment 9 Krzysztof Daniel CLA 2008-08-25 04:07:01 EDT
There is a workaround:
 go to the 'Braces' tab while editing formatter
 select 'Next line on wrap' in the 'Method declaration'

Then the opening brace will be moved to the next line if necessary.
Comment 10 Frederic Fusier CLA 2010-01-13 06:23:31 EST
*** Bug 299473 has been marked as a duplicate of this bug. ***
Comment 11 Stepan Kolesnik CLA 2014-08-19 12:53:47 EDT
Still present in 4.4
Comment 12 Mateusz Matela CLA 2015-11-30 18:05:59 EST
This problem no longer occurs after the formatter redesign.

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