Community
Participate
Working Groups
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.
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.
Released for 3.3M4.
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!
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.
(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.
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
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').
Verified for 3.3M4 with I20061212-0010.