Skip to content

Unchain into multiple statements for TYPES #94

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
jelliottp opened this issue Aug 24, 2023 · 4 comments
Closed

Unchain into multiple statements for TYPES #94

jelliottp opened this issue Aug 24, 2023 · 4 comments
Assignees

Comments

@jelliottp
Copy link

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.
@jmgrassau
Copy link
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

@AlexandreHT
Copy link

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.

@jmgrassau jmgrassau self-assigned this Nov 3, 2023
@jmgrassau
Copy link
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

@jmgrassau
Copy link
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

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

No branches or pull requests

3 participants