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
My problem: Depending on where exactly the cursor is when I start the ABAP Cleaner the results of the formatting are different and in some case maddening ;-)
Now that I know how ABAP Cleaner reacts depending on the position of the cursor I developed a sort of muscle memory in order to activate this workaround and get the expected results.
However it still hits me once in a while when I forget :-D and damn is that annoying! ;-)
Since there is some logic in this madness don't you think that there could be a solution somehow?
thanks for those examples! (By the way: when creating an issue, you can simply use Ctrl+V to paste a screenshot to GitHub, no need to refer to an external dropbox location! On Windows, I meanwhile use the shortcut Win+Shift+S a lot for screenshots).
I tried to create a minimal example for this:
TYPES:
BEGIN OF ty_s_any_struc, " comment 1
any_integer TYPE i, " comment 2name TYPE string, " comment 3END OF ty_s_any_struc.
DATA:
lo_any_ref TYPE REF TO cl_any_class_name,
lt_any_table_name TYPE TABLE OF string, " comment A
lt_other_table_name TYPE STANDARD TABLE OF ty_s_any_struc. " comment B
Things happen in cleanup rule "Align declarations":
With the "comment 2" that I added, you can see that the rule does align the comments at the end of the declarations, but the BEGIN OF line is not included in this. That explains what happens here – I can check whether this can be changed.
Regarding comment A+B, this is clearly a bug, and interestingly, the result is different without the first declaration:
Will look into it!
Regarding cursor position, what setting do you use in the main window -> Cleanup Settings -> Default cleanup range? I assume 'Current command', which would explain why only some code gets changed, depending on cursor position. If you use the ADT menu "Clean Up With Interactive ABAP Cleaner…", you can see which line range your cursor position is expanded to (everything else gets grayed out and simply won't be changed):
Re Dropbox-links vs pasted for screenshots: I pasted them first, but they didn't appear in the published issue, so I edited the issue and changed it to Dropbox-links afterwards. I'll paste one more screenshot and hope for the best;-)
Re "comment 2" on the BEGIN OF: It would be great if you could change it.
Same with the bug for A+B.
Thanks in advance!
Re Default cleanup range in Cleanup Settings: It is actually "Current method etc."
I meanwhile found out that the alignment issue in the DATA section happened because DATA … TYPE … TABLE statements are only aligned up to the TYPE keyword. Otherwise, this code …
DATA lv_pi TYPE pLENGTH10DECIMALS10VALUE'3.1415926536'.
DATA lv_e TYPE pLENGTH8DECIMALS10VALUE'2.718281828'.
DATA lt_table TYPE STANDARD TABLE OF ty_s_any_struc WITH DEFAULT KEY.
… would be aligned as …
DATA lv_pi TYPE pLENGTH10DECIMALS10VALUE'3.1415926536'.
DATA lv_e TYPE pLENGTH8DECIMALS10VALUE'2.718281828'.
DATA lt_table TYPE STANDARD TABLE OF ty_s_any_struc WITH DEFAULT KEY.
… because the TYPE 'column' is so wide. With that, however, the 'line-end comment column' cannot be properly aligned, either.
Therefore, all I could do for now is to exclude line-end comments after 'TYPE … TABLE' from alignment. This means that ABAP cleaner will not actively align them, but on the other hand, it will no more mess up manual alignment here. Hope that's fine. Again, a general solution as mentioned in #291 could help.
Will still look into line-end comments after BEGIN OF!
hmmm... I think I see it a little bit differently, because the formatting in the DATA part is:
for each line different,
the comments are not aligned to the most wide line (that would be gt_csv_file_parsed... in my screenshot) and
even the rest of each DATA-lines after TYPE (that is REF TO..., TABLE OF... and STANDARD TABLE OF...) are also not right-aligned to the end of the widest DATA-line (again gt_csv_file_parsed)
I even go so far as to say that a slight change ONLY for the comments, not for the rest of the declarations, would solve it: left-align the comments according to the widest line in the block of the DATA-declarations.
with version 1.21.3, the bug – which introduced lots of spaces between DATA … TYPE … TABLE and line-end comments – should now be fixed. However, admittedly, the overall result for line-end comments is not ideal yet.
Activity
jmgrassau commentedon Jan 7, 2025
Hi Vlad,
thanks for those examples! (By the way: when creating an issue, you can simply use Ctrl+V to paste a screenshot to GitHub, no need to refer to an external dropbox location! On Windows, I meanwhile use the shortcut Win+Shift+S a lot for screenshots).
I tried to create a minimal example for this:
Things happen in cleanup rule "Align declarations":
With the "comment 2" that I added, you can see that the rule does align the comments at the end of the declarations, but the
BEGIN OFline is not included in this. That explains what happens here – I can check whether this can be changed.Regarding comment A+B, this is clearly a bug, and interestingly, the result is different without the first declaration:
Will look into it!
Regarding cursor position, what setting do you use in the main window -> Cleanup Settings -> Default cleanup range? I assume 'Current command', which would explain why only some code gets changed, depending on cursor position. If you use the ADT menu "Clean Up With Interactive ABAP Cleaner…", you can see which line range your cursor position is expanded to (everything else gets grayed out and simply won't be changed):
Kind regards,
Jörg-Michael
VladGhitulescu commentedon Jan 7, 2025
Hi Jörg-Michael,
Thanks for the quick reply!
Re Dropbox-links vs pasted for screenshots: I pasted them first, but they didn't appear in the published issue, so I edited the issue and changed it to Dropbox-links afterwards. I'll paste one more screenshot and hope for the best;-)
Re "comment 2" on the BEGIN OF: It would be great if you could change it.
Same with the bug for A+B.
Thanks in advance!
Re Default cleanup range in Cleanup Settings: It is actually "Current method etc."
Thanks again!
Regards,
Vlad
jmgrassau commentedon Jan 8, 2025
Hi Vlad,
I meanwhile found out that the alignment issue in the DATA section happened because DATA … TYPE … TABLE statements are only aligned up to the TYPE keyword. Otherwise, this code …
… would be aligned as …
… because the TYPE 'column' is so wide. With that, however, the 'line-end comment column' cannot be properly aligned, either.
Therefore, all I could do for now is to exclude line-end comments after 'TYPE … TABLE' from alignment. This means that ABAP cleaner will not actively align them, but on the other hand, it will no more mess up manual alignment here. Hope that's fine. Again, a general solution as mentioned in #291 could help.
Will still look into line-end comments after BEGIN OF!
Kind regards,
Jörg-Michael
VladGhitulescu commentedon Jan 8, 2025
Hi Jörg-Michael,
hmmm... I think I see it a little bit differently, because the formatting in the DATA part is:
I even go so far as to say that a slight change ONLY for the comments, not for the rest of the declarations, would solve it: left-align the comments according to the widest line in the block of the DATA-declarations.
What do you think?
Regards,
Vlad
fix AlignDeclarationsRule for comments after TYPE ... TABLE (SAP#395)
fix AlignDeclarationsRule for comments after TYPE ... TABLE (#395)
jmgrassau commentedon Sep 11, 2025
Hi Vlad,
with version 1.21.3, the bug – which introduced lots of spaces between DATA … TYPE … TABLE and line-end comments – should now be fixed. However, admittedly, the overall result for line-end comments is not ideal yet.
Kind regards,
Jörg-Michael