Bug 58724 - Java code formatter should add space between imports and class definition
Summary: Java code formatter should add space between imports and class definition
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0 M9   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 49024 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-04-15 15:11 EDT by Dejan Glozic CLA
Modified: 2004-05-18 12:11 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 Dejan Glozic CLA 2004-04-15 15:11:28 EDT
I always resented this and eventually it made me open a defect report :-):

When I use auto-formatter in Java editor, it does not add any space between 
package imports and other code. This results in the following format:

import org.eclipse.ui.*;
import org.eclipse.pde.ui.*;
class Foo extends Bar {
}

This is not a good default - the code would look much better with a line to 
separate the two. Not all the classes have Javadoc comments - many are 
internal and I am tired of adding artificial Javadoc just to achieve this 
separation.
Comment 1 Dirk Baeumer CLA 2004-04-16 05:40:33 EDT
Default formatter setting are defined by JDT/Core.
Comment 2 Olivier Thomann CLA 2004-04-16 09:27:05 EDT
It is trivial to add your own profile and change the default settings.
Comment 3 Olivier Thomann CLA 2004-04-26 09:50:34 EDT
Move to JDT/Text for comment.
The default profile doesn't preserve one of the options provided by the old code
formatter settings. I should set the number of blank line to preserve to 1
instead of 0.
The old formatter doesn't add blank lines. So if no blank lines were present
between the import declarations and the type declarations, none would be inserted.

This might require some tests to be updated. This would fix two PRs.

Is it ok for you to change the default settings? I will run all your tests
changing this settings after tomorrow integration build.
Comment 4 Dani Megert CLA 2004-04-27 06:05:47 EDT
ok.
Comment 5 Olivier Thomann CLA 2004-04-27 12:29:47 EDT
Daniel,

Instead of changing jdt.ui tests, would it be possible for you to set your code
formatter options in your tests to preserve the old settings (remove all blank
lines)?
This would prevent you from updating tests when default options change.
Comment 6 Dani Megert CLA 2004-04-27 12:39:18 EDT
How can we do this? Wouldn't we have to set all preferences in fact use our own
profile?
Comment 7 Olivier Thomann CLA 2004-04-27 12:48:28 EDT
In fact it would be much better for you (to be independant from changes in the
default options) to use your own profile.
You can also simply get the default settings and change the options you want
inside the map.
Comment 8 Dani Megert CLA 2004-04-27 12:51:24 EDT
>You can also simply get the default settings and change the options you want
>inside the map.
Yep - but then we stil depend on the defaults not being changed.
Comment 9 Olivier Thomann CLA 2004-04-27 15:57:09 EDT
3 tests need to be updated in jdt.ui tests AddUnimplementedConstructorsTest. So
we need to synchronize these changes.

By using your own profile, you could define a profile that is using current
default values (not relying on defaults). Then you would not be affected by
changes in the default settings. You might however be affected by fixes in the
code formatter.
Comment 10 Dani Megert CLA 2004-04-28 02:57:13 EDT
If you send me a (working ;-) JCore preview I can do it anytime. JDT UI then
uses the preview.
Comment 11 Olivier Thomann CLA 2004-04-29 11:28:27 EDT
Changed the default settings to preserve one blank line.
Comment 12 Olivier Thomann CLA 2004-04-29 11:31:56 EDT
If you want a new line to be added, then update your code formatter profile.
Comment 13 Olivier Thomann CLA 2004-04-30 11:22:11 EDT
*** Bug 49024 has been marked as a duplicate of this bug. ***
Comment 14 David Audel CLA 2004-05-18 12:11:24 EDT
Verified for 3.0M9