Bug 52305 - Code Formatter strips blank lines in methods and field definitions when I try to tell it not to
Summary: Code Formatter strips blank lines in methods and field definitions when I try...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 3.0 M8   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-02-17 16:48 EST by Ben Christensen CLA
Modified: 2004-03-25 08:00 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ben Christensen CLA 2004-02-17 16:48:22 EST
When blank lines are left inside a method, or for example in the field definitions, the code formatter 
still removes them and places them all together, regardless of whether I've set the properties:
 Number of empty lines to preserver = 10
and
 Preserve existing line breaks = true

Example:

public class MyClass {

private int ONE =1;
private int TWO = 2;

private int THREE = 3;
private int FOUR = 4;


 private void myMethod() {
  int myNewInt = FOUR+TWO;

  System.out.println("FOUR+TWO: " + myNewInt);
 }
}

This would become the following even with a new profile set with the properties above. Note: I've set 
"blank lines after fields to 0" because I want to manage spacing myself.

public class MyClass {

private int ONE =1;
private int TWO = 2;
private int THREE = 3;
private int FOUR = 4;


 private void myMethod() {
  int myNewInt = FOUR+TWO;
  System.out.println("FOUR+TWO: " + myNewInt);
 }
}


Often, when I have complex field definitions of methods, I want to use spaces to organize the code ... 
but I can't now, and therefore Code Formatter ruins my entire file ... it worked fine up until 3.0M6, but 
M7 introduced the new formatter and I can't use it until this is remedied ... and it's a major annoyance 
to not be able to use code formatter.

Am I missing a setting that I need to use, do the two that I'm using just not work, or should there be 
another property?

Thanks


Ben
Comment 1 Olivier Thomann CLA 2004-02-18 09:45:09 EST
Do not set this option.
Preserve existing line breaks = true
Put it to false.
I will investigate.
Comment 2 Ben Christensen CLA 2004-02-18 14:44:34 EST
Okay, taking out the "Preserve existing line breaks = true" made it work so I can use it ... interesting 
how I didn't come across that combination before. Thanks for the tip ...

However, how is "Preserve existing line breaks = true" supposed to work then? Based upon the preview 
window it appears to be for keeping line breaks I've put in.

For example, if I've put a line break in my comments, or something, is that not what it's supposed to 
do, keep it there?

In any rate -- whether this is a user error, a bug, or just a weird difficult setup, thanks for your 
assistance, and perhaps what needs to be done is just add more default profiles, particularly the normal 
default being the same as M6 and earlier. And perhaps better explanations of certain attributes -- or 
behavior that is more inline with it's apparent description.

Thanks.
Comment 3 Olivier Thomann CLA 2004-02-18 15:01:42 EST
I plan to get rid of the "preserve user line breaks" option. This option never
worked the way people expect it to work. It simply preserve a line break where
you had one. The problem is that this has huge side-effect on the wrapping line
mecanism.
Comment 4 Olivier Thomann CLA 2004-02-23 13:00:39 EST
The option "preserve user line breaks" has been removed from the code formatter.
It will be removed from the UI soon.
Fixed and released in HEAD.
Comment 5 Frederic Fusier CLA 2004-03-25 08:00:18 EST
Verified for 3.0 using build I200403250010.