-
Notifications
You must be signed in to change notification settings - Fork 381
feat: implement 'convert to named lambda parameters' code action #6669
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
feat: implement 'convert to named lambda parameters' code action #6669
Conversation
6fd2149
to
601c8f7
Compare
601c8f7
to
0eabc2e
Compare
I wonder if we need to add a new method for this. Ideally each new code action feature would be able to reuse an existing method. Would it possible to implements it with the scalameta parser only? We could use go to type definition on wildcards to obtain its type symbol and construct a new name out of it. Alternatively, we could add a more universal method such as (ActionType interface should be binary compatible I think 🤔 otherwise we can use a string and some separate config parameter) CompletableFuture<List<TextEdit>> codeAction(OffsetParams params, ActionType actionType) { Adding a new method for each code action causes the interfaces to bloat and more complex to the users, which is why I am hesitant to continue with that. |
Using only the scalameta parser would be ideal, but my concern is that it isn't that obvious how to find the reference of the correct wildcard parameter. With |
There is only one, no? Not sure if I understand 🤔 |
I mean that there could be multiple wildcard params for one lambda and there can be nested wildcard lambdas. Plus the rules for resolving a wildcard param into its owning lambda are not 100% clear to me. In |
Ach, if it's more difficult with the scalameta parser then do not worry about that. I would however try to add a more universal interface for code actions |
0eabc2e
to
746a923
Compare
746a923
to
24383a3
Compare
Associated Metals PR: scalameta/metals#6669 Add a code action that converts a wildcard lambda to a lambda with named parameters. It supports Scala 3 only at the moment. e.g.  
24383a3
to
9ae0a02
Compare
...s/src/main/scala/scala/meta/internal/metals/codeactions/ConvertToNamedLambdaParameters.scala
Outdated
Show resolved
Hide resolved
…#22799) Associated Metals PR: scalameta/metals#6669 Add a code action that converts a wildcard lambda to a lambda with named parameters. It supports Scala 3 only at the moment. e.g.   [Cherry-picked 43118de]
84e8e7d
to
0091b56
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
…#22799) Associated Metals PR: scalameta/metals#6669 Add a code action that converts a wildcard lambda to a lambda with named parameters. It supports Scala 3 only at the moment. e.g.  
Associated dotty PR: scala/scala3#22799
Add a code action that converts a wildcard lambda to a lambda with named parameters. It supports Scala 3 only at the moment.
e.g.


Disclaimer: I'm not sure what I'm doing 😃