You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can you check if it's not automatically aligned after unchaining by the align declarations rule? You can see which rules applied in the preview window. I was also a bit surprised alignment across multiple statements is a feature here (#14 (comment)).
generally, ABAP cleaner does NOT try to do everything within the same cleanup rule, so if you feed
PARAMETERS:
p_short type i , ##PRAGMA_IN_WRONG_POSITION
p_longer TYPE CHAR20 .
into the "Unchain into multiple statements" rule (using "Examples: Paste" in the profiles editor with activated "Unchain simple commands" option), you will get
PARAMETERS p_short type i . ##PRAGMA_IN_WRONG_POSITIONPARAMETERS p_longer TYPE CHAR20 .
So, upper/lower case is unchanged, spaces before comma / period are unchanged, pragma is still in wrong position, TYPE is still aligned.
So I think what you're actually missing is a cleanup rule to unalign declarations (unless they are chained). That's surely among the controversial topics (at least from my experience) … but admittedly, you're in line with the style guide here, while the "Align declarations" rule is not. That's why the "Align declarations" rule shows "<->" (indicating contradiction) in the references …
… and is inactive in the 'essential' profile.
So – you are basically asking for an option allowing to choose whether to a) align or b) unalign TYPE, right? – I guess adding this to the "Align declarations" rule would be clearer than having two contradicting rules ("Align declarations" and "Unalign declarations").
The other options such as "Align across empty lines" etc. could be grayed out if "unalign" is selected (cp. the "Auto-determine" option in the "Convert upper and lower case" rule).
in the next release, the "Align declarations" rule will allow you to specify how much alignment you want:
You can select this independently for chains, non-chains, and structures (because Pretty Printer behaves differently for those, too). Everything that is not aligned can be condensed with the last option, thus removing spaces from any previous alignment.
So, with "align name, TYPE, LENGTH, VALUE etc." and activated "Condense …", you get:
CONSTANTS: lc_any_price TYPE ty_price VALUE1200,
lc_other_price TYPE ty_price VALUE1000,
lc_num_contract_change TYPE ty_sequence_number VALUE1,
lc_start_date TYPE ty_start_date VALUE'20220312'.
CONSTANTS lc_pi TYPE pLENGTH10DECIMALS10VALUE'3.1415926536'.
CONSTANTS lc_e TYPE pLENGTH8DECIMALS10VALUE'2.718281828'.
CONSTANTS lc_sqrt_2 TYPE pLENGTH8DECIMALS4VALUE'1.4142'.
CONSTANTS lc_sqrt_32 TYPE pLENGTH8DECIMALS10VALUE'5.6568542495'.
With "align name and TYPE" and activated "Condense …":
CONSTANTS: lc_any_price TYPE ty_price VALUE1200,
lc_other_price TYPE ty_price VALUE1000,
lc_num_contract_change TYPE ty_sequence_number VALUE1,
lc_start_date TYPE ty_start_date VALUE'20220312'.
CONSTANTS lc_pi TYPE pLENGTH10DECIMALS10VALUE'3.1415926536'.
CONSTANTS lc_e TYPE pLENGTH8DECIMALS10VALUE'2.718281828'.
CONSTANTS lc_sqrt_2 TYPE pLENGTH8DECIMALS4VALUE'1.4142'.
CONSTANTS lc_sqrt_32 TYPE pLENGTH8DECIMALS10VALUE'5.6568542495'.
With "align name only" and activated "Condense …":
CONSTANTS: lc_any_price TYPE ty_price VALUE1200,
lc_other_price TYPE ty_price VALUE1000,
lc_num_contract_change TYPE ty_sequence_number VALUE1,
lc_start_date TYPE ty_start_date VALUE'20220312'.
CONSTANTS lc_pi TYPE pLENGTH10DECIMALS10VALUE'3.1415926536'.
CONSTANTS lc_e TYPE pLENGTH8DECIMALS10VALUE'2.718281828'.
CONSTANTS lc_sqrt_2 TYPE pLENGTH8DECIMALS4VALUE'1.4142'.
CONSTANTS lc_sqrt_32 TYPE pLENGTH8DECIMALS10VALUE'5.6568542495'.
Activity
fabianlupa commentedon May 26, 2023
Can you check if it's not automatically aligned after unchaining by the align declarations rule? You can see which rules applied in the preview window. I was also a bit surprised alignment across multiple statements is a feature here (#14 (comment)).
ConjuringCoffee commentedon May 26, 2023
I should have mentioned this: The rule "Align declarations" is inactive for these examples.
jmgrassau commentedon May 26, 2023
Hi ConjuringCoffee and Fabian,
generally, ABAP cleaner does NOT try to do everything within the same cleanup rule, so if you feed
into the "Unchain into multiple statements" rule (using "Examples: Paste" in the profiles editor with activated "Unchain simple commands" option), you will get
So, upper/lower case is unchanged, spaces before comma / period are unchanged, pragma is still in wrong position, TYPE is still aligned.
So I think what you're actually missing is a cleanup rule to unalign declarations (unless they are chained). That's surely among the controversial topics (at least from my experience) … but admittedly, you're in line with the style guide here, while the "Align declarations" rule is not. That's why the "Align declarations" rule shows "<->" (indicating contradiction) in the references …
… and is inactive in the 'essential' profile.
So – you are basically asking for an option allowing to choose whether to a) align or b) unalign TYPE, right? – I guess adding this to the "Align declarations" rule would be clearer than having two contradicting rules ("Align declarations" and "Unalign declarations").
The other options such as "Align across empty lines" etc. could be grayed out if "unalign" is selected (cp. the "Auto-determine" option in the "Convert upper and lower case" rule).
Kind regards,
Jörg-Michael
ConjuringCoffee commentedon May 26, 2023
You got it right, Jörg-Michael. 👍
[-]Unchain into multiple statements: Remove alignment?[/-][+]Feature request: Un-align declarations[/+]jmgrassau commentedon Jun 11, 2023
Hi ConjuringCoffee,
in the next release, the "Align declarations" rule will allow you to specify how much alignment you want:
You can select this independently for chains, non-chains, and structures (because Pretty Printer behaves differently for those, too). Everything that is not aligned can be condensed with the last option, thus removing spaces from any previous alignment.
So, with "align name, TYPE, LENGTH, VALUE etc." and activated "Condense …", you get:
With "align name and TYPE" and activated "Condense …":
With "align name only" and activated "Condense …":
So the choice is now yours ;-)
Kind regards,
Jörg-Michael
enhance AlignDeclarationsRule with option for 'Action', 'Condense' (S…
enhance AlignDeclarationsRule with option for 'Action', 'Condense' (#35)
jmgrassau commentedon Jun 12, 2023
Hi ConjuringCoffee and Fabian,
this is now available in release 1.4.0!
Kind regards,
Jörg-Michael