abap-cleaner icon indicating copy to clipboard operation
abap-cleaner copied to clipboard

"Remove needless spaces": Support for PARAMETERs

Open ConjuringCoffee opened this issue 2 years ago • 1 comments

Hi Jörg-Michael, during the testing of #35 I found an example which doesn't fully work. I'm opening a new issue because the change being done isn't attributed to "Align declarations", but to "Remove needless spaces".

PARAMETERS p_test1       RADIOBUTTON GROUP 1.
PARAMETERS p_test2    RADIOBUTTON GROUP 1.
PARAMETERS p_test3 AS CHECKBOX.

After:

PARAMETERS p_test1 RADIOBUTTON GROUP 1.
PARAMETERS p_test2    RADIOBUTTON GROUP 1.
PARAMETERS p_test3 AS CHECKBOX.

Parameter p_test2 is not un-aligned correctly. If I also change the alignment of p_test3, then it works correctly.

Before:

PARAMETERS p_test1       RADIOBUTTON GROUP 1.
PARAMETERS p_test2    RADIOBUTTON GROUP 1.
PARAMETERS p_test3  AS CHECKBOX.

After and expected:

PARAMETERS p_test1 RADIOBUTTON GROUP 1.
PARAMETERS p_test2 RADIOBUTTON GROUP 1.
PARAMETERS p_test3 AS CHECKBOX.

Here are my settings:

image

image

ConjuringCoffee avatar Jun 12 '23 13:06 ConjuringCoffee

Hi ConjuringCoffee,

yes, this is a bit of a functional gap – "Align declarations" so far doesn't consider PARAMETERS, but is focused on the kind of declarations that you will find in classes.

I can explain the behavior of "Remove needless spaces" here. As you can see from the description, this cleanup rule tries to "Remove multiple spaces where no alignment intention can be identified." For this, the cleanup rule looks up and down to see whether there is some alignment (among similar token types) which might have been intentional. In this case,

PARAMETERS p_test1 RADIOBUTTON GROUP 1.
PARAMETERS p_test2    RADIOBUTTON GROUP 1.
PARAMETERS p_test3 AS CHECKBOX.

there are actually two keywords which are aligned: RADIOBUTTON in the second line and CHECKBOX in the third line. Therefore, ABAP cleaner preserves this alignment (although, of course, the human reader immediately knows that this was NOT intended; but ABAP cleaner is deterministic, not AI-based…).

In your second example, there is no such alignment, therefore ABAP cleaner is "confident" that there is no deep reason to these extra spaces.

Kind regards, Jörg-Michael

jmgrassau avatar Jun 12 '23 15:06 jmgrassau