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

Show parameter name in methods for simple types #184

Open
tgodzik opened this issue Feb 1, 2021 · 8 comments
Open

Show parameter name in methods for simple types #184

tgodzik opened this issue Feb 1, 2021 · 8 comments
Assignees

Comments

@tgodzik
Copy link
Contributor

tgodzik commented Feb 1, 2021

Is your feature request related to a problem? Please describe.
With code like:

def easyMethod(boolParam: Boolean) = ???
easyMethod(true)

it would be good to show name of the parameter so that we see:
easyMethod(boolParam = true)

The same should probably apply to Int, Double, Float.

Describe the solution you'd like
We should be able to achieve it via decorations, similar to how we do it in case of type decorations. The main difficulty here is making sure the we don't search for the name each time a request is made, since there might a larger number of methods and we load decorations for the entire file at the same time.

Describe alternatives you've considered
Writing it manually always.

Additional context
This is a follow up from #21

Search terms:
named parameters decorations inferred information

@dgalichet
Copy link

This could be a really nice feature. Maybe also a code action to permanently add the parameter names in the code ?

@tgodzik
Copy link
Contributor Author

tgodzik commented Aug 24, 2021

This could be a really nice feature. Maybe also a code action to permanently add the parameter names in the code ?

This can actually be a much simpler thing to do. Could you open a separate feature request?

@dgalichet
Copy link

Of course, did it :) thanks a lot @tgodzik

@tanishiking
Copy link
Member

Hey, is anybody already working on this? Since this is one of the most features I miss from the IntelliJ Scala Plugin, I'm willing to work on this maybe next weekend :)

@tgodzik
Copy link
Contributor Author

tgodzik commented Sep 7, 2021

@tanishiking no one that I know of, this would be awesome!

@tanishiking
Copy link
Member

So, this should be possible using compiler API.
However, for the performance sake, it might be better to have information on the parameter name in SemanticDB, otherwise, every time we open a file, Metals lookup all the parameter names of the symbols in a file.
For Scala3, tasty may already have that kind of information.

@tgodzik
Copy link
Contributor Author

tgodzik commented Apr 28, 2022

So, this should be possible using compiler API. However, for the performance sake, it might be better to have information on the parameter name in SemanticDB, otherwise, every time we open a file, Metals lookup all the parameter names of the symbols in a file. For Scala3, tasty may already have that kind of information.

Another possibility would be to cache signatures for methods workspace wide, but that would add a lot of memory overhead I feel.

Using the presentation compiler might not actually be that bad since we already get typed tree each time we open a file, so we would get that information anyway. It would be good to benchmark the approach before going this way though.

@tanishiking tanishiking self-assigned this May 11, 2022
@tanishiking
Copy link
Member

tanishiking commented May 12, 2022

Some progress 🎉
Screen Shot 2022-05-12 at 15 46 39

  • The infix parameters shouldn't have decorations
  • Cache the result of paramName calculation
  • Strange behavior when it's work with other decoration features.

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

3 participants