Skip to content

"Align declarations": Line break if the line gets too long #77

New issue

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

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

Already on GitHub? # to your account

Closed
ConjuringCoffee opened this issue Jul 18, 2023 · 4 comments
Closed

"Align declarations": Line break if the line gets too long #77

ConjuringCoffee opened this issue Jul 18, 2023 · 4 comments
Assignees

Comments

@ConjuringCoffee
Copy link
Contributor

ConjuringCoffee commented Jul 18, 2023

Hi Jörg-Michael, the rule "Align declarations" doesn't seem to have any logic to add or keep line breaks if the line gets too long.

Example:

INTERFACE lif_example_interface.
  TYPES this_is_a_type_name TYPE char1.

  CONSTANTS:
    BEGIN OF values_for_the_type,
      first_value TYPE this_is_a_type_name VALUE 'A',
    END OF values_for_the_type.

ENDINTERFACE.


CLASS lcl_example DEFINITION CREATE PRIVATE.

  PUBLIC SECTION.

  PROTECTED SECTION.

  PRIVATE SECTION.
    DATA this_is_an_attribute TYPE lif_example_interface=>this_is_a_type_name VALUE lif_example_interface=>values_for_the_type-first_value.
ENDCLASS.


CLASS lcl_example IMPLEMENTATION.

ENDCLASS.

In this case I'd like to be able to put VALUE lif_example_interface=>values_for_the_type-first_value on a new line. The ABAP Cleaner rule doesn't allow this.

Here are the options I am using:

image

@ConjuringCoffee ConjuringCoffee changed the title "Align declarations": Line-break if the line gets too long "Align declarations": Linebreak if the line gets too long Jul 18, 2023
@ConjuringCoffee ConjuringCoffee changed the title "Align declarations": Linebreak if the line gets too long "Align declarations": Line break if the line gets too long Jul 18, 2023
@jmgrassau
Copy link
Member

Hi ConjuringCoffee,

I haven't encountered such an example yet, but of course it makes sense to break the line here. So, I think an option for maximum line length should be added. However, where exactly would you expect VALUE to be moved? Maybe below TYPE? Or below the variable name?

Kind regards,
Jörg-Michael

@ConjuringCoffee
Copy link
Contributor Author

I think the following two approaches would look good:

    DATA this_is_an_attribute TYPE  lif_example_interface=>this_is_a_type_name 
                              VALUE lif_example_interface=>values_for_the_type-first_value.
    DATA this_is_an_attribute TYPE lif_example_interface=>this_is_a_type_name 
                              VALUE lif_example_interface=>values_for_the_type-first_value.

@jmgrassau jmgrassau self-assigned this Jul 28, 2023
@jmgrassau
Copy link
Member

Hi ConjuringCoffee,

thanks for this issue! I now added a new option to the "Align declarations" rule:

image

This changes

    DATA this_is_an_attribute TYPE lif_example_interface=>this_is_a_type_name VALUE lif_example_interface=>values_for_the_type-first_value.

into

    DATA this_is_an_attribute TYPE lif_example_interface=>this_is_a_type_name
                              VALUE lif_example_interface=>values_for_the_type-first_value.

or – if you'd only allow a maximum line length of 89 or less – even into

    DATA this_is_an_attribute TYPE lif_example_interface=>this_is_a_type_name
         VALUE lif_example_interface=>values_for_the_type-first_value.

This also works in the other direction, moving VALUE clauses behind the type if maximum line length allows for it.

Kind regards,
Jörg-Michael

@jmgrassau
Copy link
Member

Hi ConjuringCoffee,

the new option is now available with version 1.5.1 which was just released!

Kind regards,
Jörg-Michael

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants