Skip to content

Unchain into multiple statements for TYPES #94

Closed

Description

@jelliottp

I'd like to see this rule extended to work also for TYPES. Ideally we should unchain these just like constants, variables, methods, etc.

Before:

TYPES: BEGIN OF type1,
         field1 TYPE data,
       END OF type1,
       type2 TYPE STANDARD TABLE OF type1.
       BEGIN OF type3,
         field3 TYPE data,
       END OF type3.
       type3 TYPE STANDARD TABLE OF type3,

After:

TYPES: 
  BEGIN OF type1,
    field1 TYPE data,
  END OF type1.
TYPES type2 TYPE STANDARD TABLE OF type1.
TYPES: 
  BEGIN OF type3,
    field3 TYPE data,
  END OF type3.
TYPES type3 TYPE STANDARD TABLE OF type3.

Activity

  1. jmgrassau commented on Sep 2, 2023

    @jmgrassau
    Member

    Hi Josh,

    yes, that absolutely makes sense, and guess which comment I found inside the ChainRule code:

       // TODO: chains that just *contain* a BEGIN OF ... END OF section may nevertheless be partly unchained ...
       if (command.getFirstToken().matchesOnSiblings(true, TokenSearch.ASTERISK, "BEGIN OF"))
          return false;

    So, currently, the rule skips any TYPES command that contains BEGIN OF anywhere, but it would be nice to unchain those, while keeping BEGIN OF ... END OF blocks together where possible (unless they are anyway interrupted by an annoying INCLUDE…)

    Kind regards,
    Jörg-Michael

  2. AlexandreHT commented on Sep 29, 2023

    @AlexandreHT

    Hi,
    I must admit I prefer chaining structure and table declaration. The finest result would be to have an option for the following result

    TYPES:  BEGIN OF ty_type1,
              field1 TYPE data,
            END OF ty_type1,
            tty_type1 TYPE STANDARD TABLE OF ty_type1.
    
    TYPES:  BEGIN OF ty_type2,
              field3 TYPE data,
            END OF ty_type2,
            tty_type2 TYPE STANDARD TABLE OF ty_type2.

    but I agree it complicates a bit the rule.

  3. self-assigned this
    on Nov 3, 2023
  4. jmgrassau commented on Nov 3, 2023

    @jmgrassau
    Member

    Hi Josh,

    thanks for bringing this up! With the next release, "Unchain into multiple statements" will now also work on TYPES chains that contain BEGIN OF … END OF definitions, if they are not interrupted by an INCLUDE (sorry, that case would really complicate things too much, but I think most cases are simple cases):

    image

    @AlexandreHT: Nice point! For this, I added the following option, which is activated by default:
    image

    With that, you get:

    image

    Kind regards,
    Jörg-Michael

  5. jmgrassau commented on Nov 6, 2023

    @jmgrassau
    Member

    Hi Josh,

    thanks for pointing this out – the enhancement (as described above) is now available in version 1.11.0 which was just released!

    Kind regards,
    Jörg-Michael

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions