-
Notifications
You must be signed in to change notification settings - Fork 381
feature: Add inlay hints for named parameters #7400
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
Conversation
b26b879
to
270af1e
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.
I feel like it would be cool to have inlay hints for only "useful" named params. Not necessarily instead of this but maybe additionally. We could avoid showing named params:
- for single letter param names (or
xs
,ys
), since those are usually meaningless - when param name and passed argument have the same name
mtags/src/main/scala-2/scala/meta/internal/pc/PcInlayHintsProvider.scala
Outdated
Show resolved
Hide resolved
mtags/src/main/scala-2/scala/meta/internal/pc/PcInlayHintsProvider.scala
Outdated
Show resolved
Hide resolved
This really depends on a use case. Most of the times I guess yeah, but sometimes it might be useful for some symbolic names.
I want to keep it consistent, if we don't show named params in some cases, users might actually think they are broken. |
200eff4
to
516b6ae
Compare
516b6ae
to
4c23ce7
Compare
4c23ce7
to
ff7a2cd
Compare
|""".stripMargin, | ||
"""|object Main{ | ||
| def foo(x: => Int, y: Int, z: => Int)(w: Int, v: => Int): Unit = () | ||
| foo(/*x = => */1, /*y = */2, /*z = => */3)(/*w = */4, /*v = => */5) |
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.
@harpocrates I noticed that our PR interact with each other, what do you think about the mix of named parameters and by name ones? Alternatively, we could drop '=' and have:
| foo(/*x = => */1, /*y = */2, /*z = => */3)(/*w = */4, /*v = => */5) | |
| foo(/*x => */1, /*y = */2, /*z => */3)(/*w = */4, /*v => */5) |
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.
I think seeing = =>
is probably the most reasonable thing - unfortunately in scala x => 1
starts looking like a lambda w/ arg x
. I don't have a strong opinion though...
On dropping some parameter inlay-hints when they'd probably be noise: I don't really have an opinion to add, but wanted to mention this is the approach |
ff7a2cd
to
4e2234e
Compare
Thanks! Though I think we can add the heuristics later when testing the feature and user have some specific ideas. For now I will leave it as straightforward as possible. |
| /*name = */"semanticdb-javac", | ||
| /*version = */"BuildInfo.javaSemanticdbVersion", | ||
| ), | ||
| None, |
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.
This becomes much more complex now since all the parameters are now synthetic if we reorder the params in any way (though the flag is not set in reality). I might work on it later, but I will just do a follow up issue before mergeing. TODO
4e2234e
to
10a58d5
Compare
mtags/src/main/scala-2/scala/meta/internal/pc/PcInlayHintsProvider.scala
Outdated
Show resolved
Hide resolved
10a58d5
to
7780f0e
Compare
7780f0e
to
e71499d
Compare
e71499d
to
495c4a9
Compare
Add inlay hints for name parameters. Porting scalameta/metals#7400
Scala 2 version of scalameta/metals-feature-requests#184