Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 244789 - [formatter] Java source formatter ignores maximum line width for no obvious reason
Summary: [formatter] Java source formatter ignores maximum line width for no obvious r...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Linux
: P5 normal (vote)
Target Milestone: 4.7 M2   Edit
Assignee: Mateusz Matela CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-21 05:06 EDT by Oliver Mangold CLA
Modified: 2016-09-14 01:51 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Mangold CLA 2008-08-21 05:06:18 EDT
Build ID: I20080617-2000

Steps To Reproduce:
Set maximum line width to 80 characters.
Set indentation size to 2 spaces.
Set all braces to 'same line'.

Try to format the files below:

--- Sandbox.java ------------------------
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import javax.swing.JButton;
import sun.text.normalizer.UnicodeMatcher;

public class Sandbox {

  private Map<String, ArrayList<UnicodeMatcher>> m_Matchers = new HashMap<String, ArrayList<UnicodeMatcher>>();
  private Map<String, ArrayList<JButton>> m_BlockButtons = new HashMap<String, ArrayList<JButton>>();

}
-----------------------------------------

--- SelectionModuleWithTwoInputs.java ---
abstract class AbstractSelectionModule {

}

public final class SelectionModuleWithTwoInputs extends AbstractSelectionModule {

}
-----------------------------------------

More information:
The first file maybe shows a problem with formatting generics.

The problem in the second file disappears, when the line is made one character longer (e.g. by substituting 'public' by 'abstract'). Possibly the attached brace is not counted when the line length is calculated.
Comment 1 Frederic Fusier CLA 2008-08-21 05:48:00 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 this issue to be fixed in this
version and I'll have a look at it...
TIA
Comment 2 Mateusz Matela CLA 2016-06-08 14:16:43 EDT
This problem no longer occurs after the formatter redesign.

*** This bug has been marked as a duplicate of bug 303519 ***
Comment 3 Manoj N Palat CLA 2016-08-03 02:51:47 EDT
(In reply to Mateusz Matela from comment #2)
> This problem no longer occurs after the formatter redesign.
> 
> *** This bug has been marked as a duplicate of bug 303519 ***

Mateusz: Though the line wraps for SelectionModuleWithTwoInputs it does not wrap for Sandbox.java - Can you recheck this Sandbox.java?
Comment 4 Manoj N Palat CLA 2016-08-04 03:07:25 EDT
(In reply to Manoj Palat from comment #3)
> (In reply to Mateusz Matela from comment #2)
> > This problem no longer occurs after the formatter redesign.
> > 
> > *** This bug has been marked as a duplicate of bug 303519 ***
> 
> Mateusz: Though the line wraps for SelectionModuleWithTwoInputs it does not
> wrap for Sandbox.java - Can you recheck this Sandbox.java?

Reopening and moving to M2 for re-checking
Comment 5 Mateusz Matela CLA 2016-08-16 14:43:27 EDT
(In reply to Manoj Palat from comment #3)
> Mateusz: Though the line wraps for SelectionModuleWithTwoInputs it does not
> wrap for Sandbox.java - Can you recheck this Sandbox.java?

In Sandbox.java there is nowhere to wrap with default profile, as both assignments and parameterized types have "Do not wrap" policy. Change either of those policies and lines will get wrapped.
Comment 6 Jay Arthanareeswaran CLA 2016-09-14 01:51:04 EDT
I tried the suggestion given in comment #5 and with those options corrected, wrapping works like a charm.
Comment 7 Jay Arthanareeswaran CLA 2016-09-14 01:51:24 EDT
Verified for 4.7 M2 with build I20160912-2000