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

Add filter+map to collect code action #288

Open
riiswa opened this issue Jul 21, 2022 · 2 comments · May be fixed by scalameta/metals#6969
Open

Add filter+map to collect code action #288

riiswa opened this issue Jul 21, 2022 · 2 comments · May be fixed by scalameta/metals#6969

Comments

@riiswa
Copy link

riiswa commented Jul 21, 2022

Is your feature request related to a problem? Please describe.

The following code which contains a filter followed in map (the reciprocal is also possible) can be optimized with the collect method:

List(1, 2, 3, 4).filter(_ % 2 == 0).map(_ * 2)

Describe the solution you'd like

Propose to the user the following code:

List(1, 2, 3, 4).collect { case x if x%2 == 0 => x * 2 }

Describe alternatives you've considered

.

Additional contex

No response

Search terms

code action, map, filter, collect, optimisation

@tgodzik
Copy link
Contributor

tgodzik commented Jul 22, 2022

Thanks for reporting! That looks like a great Idea!

@scarf005
Copy link

i'm interested in implementing this feature; could anyone help me with pointers on where to look for?

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

Successfully merging a pull request may close this issue.

3 participants