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

Remove the self-reference me->: Does not work in interface methods #41

Closed
ConjuringCoffee opened this issue Jun 2, 2023 · 5 comments
Closed
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@ConjuringCoffee
Copy link
Contributor

Hi Jörg-Michael, the self-reference me-> is not removed in interface methods.

Here's an example I re-created using local objects:

INTERFACE lif_test.
  METHODS from_interface.
ENDINTERFACE.


CLASS lcl_test DEFINITION CREATE PUBLIC.

  PUBLIC SECTION.
    INTERFACES lif_test.

  PROTECTED SECTION.

  PRIVATE SECTION.
    DATA mv_value TYPE i.

    METHODS in_class.
ENDCLASS.


CLASS lcl_test IMPLEMENTATION.
  METHOD lif_test~from_interface.
    me->mv_value = 1.
  ENDMETHOD.

  METHOD in_class.
    me->mv_value = 1.
  ENDMETHOD.

ENDCLASS.

Here's the result:
image

@jmgrassau jmgrassau added the enhancement New feature or request label Jun 2, 2023
@jmgrassau
Copy link
Member

Hi ConjuringCoffee,

generally, ABAP cleaner can only remove "me->" if the method signature is known – otherwise, it could not be sure in your example whether mv_value is both an attribute and at the same time an exporting parameter; in such a case, me-> would of course have to be kept in order to refer to the attribute (not the parameter).

That's why this rule usually does not work on interface methods, where the signature is usually "out of sight". Admittedly, though, that's not the case for local interfaces as in your example – so the rule could indeed be enhanced to process these cases!

Kind regards,
Jörg-Michael

@ConjuringCoffee
Copy link
Contributor Author

Hmm, I did not consider that. That's unfortunate - thanks for the explanation!

@ConjuringCoffee
Copy link
Contributor Author

I suggest adding this to the documentation of the rule. I just noticed that this limitation also impacts attributes inherited from another global class.

@jmgrassau jmgrassau added the documentation Improvements or additions to documentation label Jun 2, 2023
@jmgrassau jmgrassau self-assigned this Jun 10, 2023
@jmgrassau
Copy link
Member

Hi ConjuringCoffee,

I now added some documentation:

image

Also, local interfaces are now correctly considered, including aliases and "cascading" cases (interfaces implementing other interfaces and defining aliases for them etc.):

image

Kind regards,
Jörg-Michael

@jmgrassau
Copy link
Member

Hi ConjuringCoffee,

as mentioned before, the perfect solution is unfortunately not possible here as long as we do not introduce backend calls to ABAP cleaner; however, I think this is as good as it gets for now!

Kind regards,
Jörg-Michael

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants