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

Bug 146565

Summary: [formatter] Code Formatter: Missing options for line wraps
Product: [Eclipse Project] JDT Reporter: Kai Hofmann <powerstat>
Component: CoreAssignee: Frederic Fusier <frederic_fusier>
Status: RESOLVED WORKSFORME QA Contact:
Severity: major    
Priority: P5 CC: comp634, daniel_megert, tmp2
Version: 3.2.2Keywords: helpwanted
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
XML Formatter Profile none

Description Kai Hofmann CLA 2006-06-12 09:50:53 EDT
I configured the code formatter to create my personal style.
This works good except for 2 things I found where it adds line wraps that I don't like:

Eclipse generated:
  public void push(
    int elem)
   {
    fStack
      .addFirst(new Integer(
        elem));
   }

What I wanted:
  public void push(int elem)
   {
    fStack.addFirst(new Integer(elem));
   }

Within the options there is no setting to add/remove these line breaks (1. function declaration, 2. object/method call.
This should be customizable via the "new lines" tab.
I would call this a bug (and not a feature), because eclipse changes existing
code without having asked to do so.
Comment 1 Martin Aeschlimann CLA 2006-06-12 11:45:52 EDT
What are your settings on 'line wrapping'?
Comment 2 Kai Hofmann CLA 2006-06-13 02:28:53 EDT
Created attachment 44231 [details]
XML Formatter Profile
Comment 3 Kai Hofmann CLA 2006-06-13 02:32:19 EDT
See previous attachement for my config.
On the "New Lines" tab I have switched on everything in the block "Insert new line", aithin "Array Initializers" the "insert new line before closing brace of array initializer", and last but not least in "Annotations" the Insert new line after annotations.
On the "Control Statement" Tab everything in the block "General".
Within the "if else" block, only the "keep else if on one line".
Comment 4 Kai Hofmann CLA 2007-06-19 03:57:33 EDT
Is there some progress on this bug? it still exists in Eclipse 3.2.2 and makes using the CodeFormatter impossible.
Comment 5 Kai Hofmann CLA 2007-06-19 04:03:47 EDT
I now found the problem - "maximum line length" was set to 0 - which seems not to mean that the line length is "not limited" like in most tools.
It seems to meen here something like "insert line break as soon as possible".

So this will end in an philosphic discussion.
So I would like to suggest the following:

- Adding documentation for this
- Thinking about the meaning of "0" as maximum line length (endless vs. as soon as possible)
- Maybe an option to protect the "." against line breaks
Comment 6 Olivier Thomann CLA 2007-06-19 09:25:08 EDT
If you want the code in comment 0, why don't you simply disable the line wrapping?
Comment 7 Denis Ballant CLA 2007-10-02 12:16:08 EDT
Why don't you simply implement request number 198074 ?

That is, add an option to disable line wrapping, preserving the current line splits decided by the user.  It's the default behavior of IDEA IntelliJ and the way I'd love to have it in Eclipse as well.

Comment 8 Creo Ilbe CLA 2007-11-05 07:52:11 EST
See and vote for Bug 198074
Comment 9 Frederic Fusier CLA 2008-08-18 08:07:22 EDT
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
Comment 10 Dani Megert CLA 2013-01-11 05:02:35 EST
This works using N20130110-2000: set 'Do not wrap' for 'Qualified invocations'.