Bug 298243

Summary: [formatter] Removing empty lines between import groups
Product: [Eclipse Project] JDT Reporter: Konstantin Scheglov <Konstantin.Scheglov>
Component: CoreAssignee: Frederic Fusier <frederic_fusier>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, Olivier_Thomann, satyam.kandula, srikanth_sankaran
Version: 3.6   
Target Milestone: 3.6 M5   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Source with empty lines
none
Formatting profile
none
Proposed patch none

Description Konstantin Scheglov CLA 2009-12-19 03:16:14 EST
Build Identifier: I20091217-0819

This build of Eclipse 3.6 has problem that was not in 3.5.1.
Sometimes it remove empty lines between import groups.
This happens during formatting.

Reproducible: Always

Steps to Reproduce:
1. open compilation unit with empty lines between import groups;
2. do formatting, I use Ctrl+Shift+F
3. note that empty lines were removed.

What is interesting:
4. If you have save actions configured, including formatting, then after save (after formatting) these empty lines will be restored!
5. But if you don't do manual formatting and instead just save, then "formatting action on save" also will remove empty lines.

Weird!
Comment 1 Dani Megert CLA 2009-12-19 04:07:04 EST
>1. open compilation unit with empty lines between import groups;
>2. do formatting, I use Ctrl+Shift+F
>3. note that empty lines were removed.
Works fine for me using I20091215-1320. Can you please provide more detailed steps. Try to provide a test case that we can apply on a new workspace.

>5. But if you don't do manual formatting and instead just save, then
>"formatting action on save" also will remove empty lines.
Sounds like a different bug. This bug here is about formatting only.
Comment 2 Konstantin Scheglov CLA 2009-12-19 07:57:25 EST
Created attachment 154836 [details]
Source with empty lines

Open this file and format it.
Comment 3 Konstantin Scheglov CLA 2009-12-19 07:59:06 EST
Created attachment 154837 [details]
Formatting profile
Comment 4 Frederic Fusier CLA 2009-12-21 05:12:43 EST
This is a regression introduced while fixing bug 199265. The problem occurs only when a profile set no blank line to preserve (i.e. Blank lines to preserve = 0).
Comment 5 Frederic Fusier CLA 2009-12-21 05:17:11 EST
Created attachment 154866 [details]
Proposed patch

Test also if there are some lines to preserve between groups to know whether a call to getPreserveEmptyLines(int) method is necessary or not...
Comment 6 Frederic Fusier CLA 2009-12-21 09:36:51 EST
Released for 3.6M5 in HEAD stream.
Comment 7 Satyam Kandula CLA 2010-01-25 06:23:54 EST
Verified for 3.6M5 using Build id: I20100122-0800
Comment 8 Srikanth Sankaran CLA 2010-01-25 06:29:50 EST
Verified.