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

Code action to add import for extension method in Scala 3 #228

Closed
ckipp01 opened this issue Aug 23, 2021 · 2 comments
Closed

Code action to add import for extension method in Scala 3 #228

ckipp01 opened this issue Aug 23, 2021 · 2 comments

Comments

@ckipp01
Copy link
Member

ckipp01 commented Aug 23, 2021

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

When working in Scala 3 you will at times get diagnostics that mention that an import may fix the problem. For example I just tried using "someString".toTermName and Scala 3 returned this as a diagnostic

Diagnostics:
1. value toTermName is not a member of String, but could be made available as an extension method.
   
   The following import might fix the problem:
   
     import dotty.tools.dotc.core.Decorators.toTermName

Describe the solution you'd like

In this situation I think it'd be perfect to also have a code action that can be triggered on toTermName which will offer to add the import in the same way we treat a Not Found: diagnostic. In this case, the code action would import dotty.tools.dotc.core.Decorators.toTermName

Describe alternatives you've considered

Manually adding it.

Additional contex

No response

Search terms

Scala 3 extension code action import

@gabro
Copy link
Member

gabro commented Aug 23, 2021

I think this is exists already in terms of #105 and #141. How do I know? Because I've duplicated it too in the past (see #192).

Also worth mentioning my half-assed attempt at implementing it scalameta/metals#2536

@ckipp01
Copy link
Member Author

ckipp01 commented Aug 23, 2021

👀 I maybe didn't search before creating this like I should have 😆

Also worth mentioning my half-assed attempt at implementing it scalameta/metals#2536

I totally forgot about this!

Closing this as a duplicate.

@ckipp01 ckipp01 closed this as completed Aug 23, 2021
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