Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 549249

Summary: [formatter] Extend Blank Lines settings to remove excess lines
Product: [Eclipse Project] JDT Reporter: Mateusz Matela <mateusz.matela>
Component: CoreAssignee: Mateusz Matela <mateusz.matela>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jarthana, stepper
Version: 4.11   
Target Milestone: 4.13 M3   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/146058
https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=1e052a8f67b9f7c8dc2c3f8bb4f7cafc00966e06
Whiteboard:
Bug Depends on:    
Bug Blocks: 212867, 549255    

Description Mateusz Matela CLA 2019-07-14 08:46:54 EDT
Looking at bug 212867 and its duplicates, I think a good way to solve them is to first make a general change that will allow any blank lines settings to override the "Number of empty lines to preserve" setting and remove empty lines in respecting positions.
It can probably be useful in other situations.

I considered adding a separate twin setting for each blank line setting, but that would be an unnecessary clutter in the API. Another approach would be to reserve a bit in the setting value and use bit masks to extract the number of lines and the line deletion switch. But in the end I chose an even simpler solution: to declare that any negative value means that line deletion is on and the actual number of blank lines is ~x (bitwise negation).

Turns out that one setting in the formatter already had line deletion feature hardcoded in: blank lines between import groups. To be super strict, we should perform profile migration in the next version and change that setting to ~x to keep the old behavior. But I don't think it's very important. It's hard to notice this feature, and turning it off will not affect previously formatted code.
Comment 1 Eclipse Genie CLA 2019-07-14 15:40:46 EDT
New Gerrit change created: https://git.eclipse.org/r/146058
Comment 3 Jay Arthanareeswaran CLA 2019-08-21 10:25:48 EDT
Verified for 4.13 M3 using build I20190820-1800
Comment 4 Mateusz Matela CLA 2020-10-25 17:09:26 EDT
*** Bug 247928 has been marked as a duplicate of this bug. ***