Bug 165210 - Fup of bug 74997, add new formatter option for number of blank lines between import groups
Summary: Fup of bug 74997, add new formatter option for number of blank lines between ...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 M4   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 74997
Blocks: 165211
  Show dependency tree
 
Reported: 2006-11-20 15:02 EST by Olivier Thomann CLA
Modified: 2006-12-12 12:21 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2006-11-20 15:02:17 EST
Right now the number of blank lines added by the fix for bug 74997 are not preserved once the code is formatted.
We should add a new code formatter option that specifies the number of blank lines between import groups. This should take precedence over the number of blank lines to preserve.
If we don't do this, we end up with inconsistencies between the organize import operation and the code formatter.
Comment 1 Olivier Thomann CLA 2006-11-20 16:14:19 EST
I have a fix that preserves the number of lines between import groups once Organize imports have been executed.
We have to make sure that we are sharing this value between organize imports and the code formatter.
Comment 2 Olivier Thomann CLA 2006-11-20 19:44:54 EST
Released for 3.3M4.
Comment 3 Martin Aeschlimann CLA 2006-11-21 05:43:23 EST
The functionality doesn't seem to work 100% yet, see the preview example from the code formatter page released in I20061121.

Also: The Javadoc of FORMATTER_BLANK_LINES_BETWEEN_IMPORT_GROUPS says that the default is '0'. Should be '1' (which seems to be whats implemented).

I fixed the ImportRewriter to use the new preference!
Comment 4 Martin Aeschlimann CLA 2006-11-21 05:47:10 EST
Note that setting should not only limit the number of empty lines between import groups, but introduce that number of new lines. This is consistent with the other settings in the 'Blank lines in compilation unit' group.

As mentioned, of course it can't introduce new groups: If there is no empty line between imports, it will stay like this.
Comment 5 Olivier Thomann CLA 2006-11-21 13:44:19 EST
(In reply to comment #4)
> Note that setting should not only limit the number of empty lines between
> import groups, but introduce that number of new lines. This is consistent with
> the other settings in the 'Blank lines in compilation unit' group.
My understanding was that Organize imports would set the number of blank lines and the code formatter simply had to make sure to preserve them.
Comment 6 Olivier Thomann CLA 2006-11-21 14:49:20 EST
Released for 3.3M4.
Martin, let me know if this behaves as expected.
Added regression tests org.eclipse.jdt.core.tests.formatter.FormatterRegressionTests#test633/640
Comment 7 Martin Aeschlimann CLA 2006-11-22 04:54:52 EST
Looks great! I agree that it would be possible to say that the formatter should just preserve the lines, but I think it's more consistent if it woks like the other options in this group do (for example 'lines before imports').
Comment 8 David Audel CLA 2006-12-12 12:21:17 EST
Verified for 3.3M4 with I20061212-0010.