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

Bug 549774

Summary: [formatter] Change semantics of Blank lines before member declarations: 'before' -> 'between'
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
Version: 4.13   
Target Milestone: 4.13 M3   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/147009
https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=9acb7086514502a716e3f5a9596c8a76f9aa0b8c
Whiteboard:
Bug Depends on:    
Bug Blocks: 550083    

Description Mateusz Matela CLA 2019-08-03 19:21:56 EDT
I think the setting name "Blank lines within class declaration -> Before declarations of the same kind" is phrased rather awkwardly. It actually works and is much easier to understand as "Between declarations of different kind".

Other settings in this group, like "Before method declarations", etc. would also be described better using "Between" instead of "Before". The "Before" phrasing currently does make some sense, because for example the "Before method declarations" affects blank lines not only between two method declarations, but also between a field declaration and a method declaration. So at this spot the "Before method declarations" setting conflicts with the "Before declarations of the same kind" setting. To resolve the conflict, the formatter uses the greater of the two values.

This conflict resolution becomes more complicated with the introduction of the "Remove excess blank lines" feature (bug 549255). What if "Before method declarations" has it turned on and "Between declarations of different kind" does not, or vice versa - should excess lines be removed? What if both have it turned on - shouldn't the formatter then use the lesser number of lines?

I propose to avoid this conflict altogether and make things simpler by having each spot affected by only one setting. So blank lines between a field and a method are affected only by the "Between declarations of different kind" setting. Then there's the "Between method declarations" setting which doesn't conflict.

In practice this change will only be noticeable with profiles where the value for "Before declarations of the same kind" is smaller than "Before method declarations" or similar settings. I assume it's a very rare scenario which doesn't make much practical sense, so the change shouldn't anger many users :)

This bug is for simplifying the use of blank lines settings on body declarations. The change will not be reflected in public API: changing the preference names would introduce too much chaos and their descriptions are not really specific anyway. I'll add another bug for UI to change the settings labels.
Comment 1 Eclipse Genie CLA 2019-08-03 19:50:13 EDT
New Gerrit change created: https://git.eclipse.org/r/147009
Comment 3 Jay Arthanareeswaran CLA 2019-08-21 10:04:49 EDT
Verified for 4.13 M3 using build I20190820-1800