Bug 203588 - [formatter] Qualified invocation + binary expressions excessive wrap
Summary: [formatter] Qualified invocation + binary expressions excessive wrap
Status: VERIFIED DUPLICATE of bug 59891
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.6 M7   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-17 09:25 EDT by Mauro Molinari CLA
Modified: 2010-04-27 09:20 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mauro Molinari CLA 2007-09-17 09:25:55 EDT
Build ID: I20070625-1500

Steps To Reproduce:
1. suppose you have the following options for the formatter:
- maximum line width 80
- default indentation for wrapped lines 2
- use spaces only
- indentation size 2
- tab size 2
- for binary expressions, wrap only when necessary, default indentation
- for qualified invocations, wrap only when necessary, default indentation
- a blank line for the opening brace of "if" statement
2. suppose you have the following line of code:

public void a()
{
  if(true)
  {
    allocation.add(idx_ta + 1, Double.valueOf(allocation.get(idx_ta).doubleValue() + q));
  }
}

3. invoke code formatter

EXPECTED BEHAVIOUR:
I would expect the following output:

public void a()
{
  if(true)
  {
    allocation.add(idx_ta + 1, Double.valueOf(allocation.get(idx_ta)
          .doubleValue() + q));
  }
}

OBSERVED BEHAVIOUR:
The result is:

public void a()
{
  if(true)
  {
    allocation.add(idx_ta + 1, Double.valueOf(allocation.get(idx_ta)
          .doubleValue()
          + q));
  }
}


More information:
It seems that the formatter, when wrapping the binary expression, thinks that the end-of-line is that of the first line (allocation.add(etc.)), instead of that of the second line (.doubleValue()), so that the second line remains much shorter than it could be and "+ q" is wrapped on the third line.
Comment 1 Frederic Fusier CLA 2009-10-02 11:28:49 EDT
another wrapping to be improved...

*** This bug has been marked as a duplicate of bug 59891 ***
Comment 2 Olivier Thomann CLA 2010-04-27 09:20:36 EDT
Verified for 3.6M7 using I20100426-0852.
The line wrapping is improved now.