Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comments - again :-/ #395

Open
VladGhitulescu opened this issue Jan 5, 2025 · 4 comments
Open

Comments - again :-/ #395

VladGhitulescu opened this issue Jan 5, 2025 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@VladGhitulescu
Copy link

VladGhitulescu commented Jan 5, 2025

Hello

and a happy new year to you all!

I must re-address the issue of formatting the comments (see also my initial gripe with it in the Issue #291 here).

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 ;-)

Here comes my example.

I have an include with global declarations.

When I position the cursor in the line 4 the result after ABAP Cleaner looks like this.
This is what I expected, everything is ok.

Placing the cursor in line 14 produce this result (the changed comment is in the line 16).
Hmmm…

And - God forbid! ;-) - when the cursor is in line 38 the comments... well, they go as wild as back in April 2024 when I first address this issue (the changed comments are in the lines 41 and 42).

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!

Regards,
Vlad

@jmgrassau jmgrassau added the bug Something isn't working label Jan 7, 2025
@jmgrassau
Copy link
Member

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:

TYPES:
  BEGIN OF ty_s_any_struc,      " comment 1
    any_integer TYPE i,         " comment 2
    name        TYPE string,    " comment 3
  END 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":

Image

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:

Image

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):

Image

Kind regards,
Jörg-Michael

@VladGhitulescu
Copy link
Author

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."

Image

Thanks again!

Regards,
Vlad

@jmgrassau jmgrassau self-assigned this Jan 8, 2025
@jmgrassau
Copy link
Member

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 …

    DATA lv_pi    TYPE p LENGTH 10 DECIMALS 10 VALUE '3.1415926536'.
    DATA lv_e     TYPE p LENGTH 8  DECIMALS 10 VALUE '2.718281828'.
    DATA lt_table TYPE STANDARD TABLE OF ty_s_any_struc WITH DEFAULT KEY.

… would be aligned as …

    DATA lv_pi    TYPE p                                                 LENGTH 10 DECIMALS 10 VALUE '3.1415926536'.
    DATA lv_e     TYPE p                                                 LENGTH 8  DECIMALS 10 VALUE '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!

Kind regards,
Jörg-Michael

@VladGhitulescu
Copy link
Author

Hi Jörg-Michael,

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.

What do you think?

Regards,
Vlad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants