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

"Align parameters and components" when using multiple indices in nested table expression #75

Closed
ConjuringCoffee opened this issue Jul 13, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@ConjuringCoffee
Copy link
Contributor

Hi Jörg-Michael, I found an example in which I don't like how alignment looks when working with multiple indices in a table expression with a nested table. Any chance you can improve this? 😊

Take the following full example:

CLASS lcl_example DEFINITION CREATE PRIVATE.

  PUBLIC SECTION.
    METHODS example.
  PROTECTED SECTION.
  PRIVATE SECTION.
    METHODS this_is_a_very_very_long_name
      IMPORTING
        i_import        TYPE bapiret2
      RETURNING
        VALUE(r_result) TYPE string.
ENDCLASS.


CLASS lcl_example IMPLEMENTATION.
  METHOD example.
    DATA table_normal TYPE bapiret2_t.
    DATA table_nested TYPE TABLE OF bapiret2_t.

    DATA(this_is_a_very_very_long__name) = NEW lcl_example( )->this_is_a_very_very_long_name( table_normal[ 1 ] ).

    DATA(this_is_a_very_very_long_name2) = NEW lcl_example( )->this_is_a_very_very_long_name( table_nested[ 1 ][ 1 ] ).
  ENDMETHOD.

  METHOD this_is_a_very_very_long_name.
  ENDMETHOD.
ENDCLASS.

I'm not really happy with the indentation of the table expression. This is the result after ABAP Cleaner was executed:

    DATA(this_is_a_very_very_long__name) = NEW lcl_example( )->this_is_a_very_very_long_name(
                                                   table_normal[ 1 ] ).

    DATA(this_is_a_very_very_long_name2) = NEW lcl_example( )->this_is_a_very_very_long_name( table_nested[
                                                                                                  1 ][ 1 ] ).

The first example is alright, but I don't like the second example. I'd have expected something like this:

    DATA(this_is_a_very_very_long_name2) = NEW lcl_example( )->this_is_a_very_very_long_name(
                                                   table_nested[ 1 ][ 1 ] ).

If I tried to manually indent it like that though, then this would be the result:

    DATA(this_is_a_very_very_long_name2) = NEW lcl_example( )->this_is_a_very_very_long_name(
                                                                                              table_nested[
                                                                                                  1 ][ 1 ] ).

Here are the settings I use:
image

@jmgrassau jmgrassau added the bug Something isn't working label Jul 21, 2023
@jmgrassau
Copy link
Member

Hi ConjuringCoffee,

yes, that second example definitely doesn't look good (although in a way it's not wrong). On the other hand, if you had a variable name here such as ```[ lv_index ]``, it could have any length between 1 and 30 chars, and at some point you'd want a line break. So, let's see what can be done about it – maybe it should simply be prevented to introduce line breaks when the content is very short.

What I'd consider a bug is the last example, because if ABAP cleaner moves table_nested[ behind the opening (, there is no reason to keep the line break. I'll have to check why that happens!

Kind regards,
Jörg-Michael

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

Hi ConjuringCoffee,

thanks again for opening this issue – this was indeed a bug, because table expressions that are chained with ][ were not processed properly. With your example and settings, I now get:

    DATA(this_is_a_very_very_long__name) = NEW lcl_example( )->this_is_a_very_very_long_name(
                                                   table_normal[ 1 ] ).

    DATA(this_is_a_very_very_long_name2) = NEW lcl_example( )->this_is_a_very_very_long_name(
                                                   table_nested[ 1 ][ 1 ] ).

Condensing also works now (without keeping unnecessary line breaks), so if you enter …

    any_method(
    lt_any_table[ 
    1 ][ 
    2 ][ 
    3 ] ).

    any_method(
    par1 = lt_any_table[ 
    1 ]
    param2 = lt_any_table[ 
    1 ][ 
    2 ]
    parameter3 = lt_any_table[ 
    1 ][ 
    2 ][ 
    3 ] ).

you will get:

    any_method( lt_any_table[ 1 ][ 2 ][ 3 ] ).

    any_method( par1       = lt_any_table[ 1 ]
                param2     = lt_any_table[ 1 ][ 2 ]
                parameter3 = lt_any_table[ 1 ][ 2 ][ 3 ] ).

And an example where a line break cannot be avoided …

    DATA(lv_some_value_with_a_long_name) = any_method(
    lt_any_table[
    lv_index ][
    lv_second_index ][
    lv_third_index_with_long_name ] ).

… will look like this:

    DATA(lv_some_value_with_a_long_name) = any_method( lt_any_table[ lv_index ][ lv_second_index ][
                                                           lv_third_index_with_long_name ] ).

Kind regards,
Jörg-Michael

@ConjuringCoffee
Copy link
Contributor Author

Great, thank you!

@jmgrassau
Copy link
Member

Hi ConjuringCoffee,

this issue should now be fixed with version 1.5.1!

Kind regards,
Jörg-Michael

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