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

ChainedMethodInvocationRefactor should be able to handle chains of arbitrary length #36

Closed
RadikalJin opened this issue May 24, 2021 · 3 comments

Comments

@RadikalJin
Copy link
Member

RadikalJin commented May 24, 2021

Describe the bug
The ChainedMethodInvocationRefactor will currently match on two chained method invocations, and swap them to a different method.

For example,
getCurrentFoo().doFooThing()
can be swapped to
doBarThing()

Expected behavior
This refactor should be updated so that:

  • Chains of arbitrary length can be matched
  • Those chains can themselves be replaced by other chains of arbitrary length, rather than just one method invocation.

For example,
getCurrentFoo()
or
getCurrentFoo().doFooThing().doOtherThing()
should be valid matchable, and replaced with
getCurrentBar().doBarThing()
or any other chain of method invocations.

Additional context
See Javadoc on ChainedMethodInvocationRefactor and associated tests for further example usage.

@monjurmorshed793
Copy link
Contributor

A test case may be provided for understanding the issue more clearly.

@RadikalJin
Copy link
Member Author

Good idea - added TestMethodInvocationRefactor.testInvocationChainedWithLargeMatchingAndReplacementChains.

monjurmorshed793 added a commit to monjurmorshed793/astra that referenced this issue Apr 5, 2022
@RadikalJin
Copy link
Member Author

Fixed by @monjurmorshed793 under PR #85

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants