Open crlf0710 opened 6 years ago
Do you mean like this?
Woah, how did you do that?
My actual goal was to do parameter hints like IntelliJ (which can be done heuristically e.g. only when there are >3 params or when multiple parameters have the same type). I could not find a way to get that information out of the compiler / from rls-analysis (would maybe need to walk the AST to find all function call tokens?).
The protocol does not support this by default, there is an open issue for VScode here: https://github.com/Microsoft/vscode/issues/16221, so I used a custom notification sent from DocumentSymbols which has the most relevant information and is called on every document change for me.
See these two patches: rls-vscode, rls.
@phiresky Nice!
TODO: how would you send a notification from a RequestAction asynchronously (without blocking?)
Why does it need to be a blocking request? We usually only use these for lifecycle requests.
I don't think the notifcation needs to be sent async - we're not waiting for a reply or anything, so sending a reply is fast.
Why does it need to be a blocking request?
The only reason I changed it to a BlockingRequestAction is because I couldn't find a way to get a reference to the Output
instance (to call output.notify
) from the ActionContext
given to the RequestAction
.
I didn't really mean async.. just meant without making the Symbols RequestAction a BlockingRequestAction. I'm not a Rust expert as you might have noticed :)
I'm also not sure if this is even the right place to put that (and who actually calls DocumentSymbols and why)
I think the right approach is to include that data in the response rather than sending a separate notification. Not sure if there are fields you can use already to do that, but if not, you can always add custom fields to the protocol messages.
What is the status on this?
@Kreyren It seems done.
@DCjanus can't confirm on my end, is there any specific configuration for this?
oh, I just made a silly mistake, I'm using rust-analyzer and I thout we are talking about it.
(I subscribed this issue long time ago, when notification came, I thout it's from rust-analyzer)
@DCjanus Can rust-analyzer do this?
I wrote a PR (#587) for this a while ago. It's not perfect, so I understand why they wouldn't want to merge it, but you can always use my fork if you want. I don't really update it much though, so you may want to keep your own fork if you want.
But yes, rust-analyzer
has implemented this feature since then. While bugs in chalk
cause type inference to fail in some cases, it still works pretty well, feel free to try it out, although the install process is a bit more complicated (at least it was last I checked).
CLion can display a "span" prompting the auto deduced type/argument name/etc. I wonder if this is possible in VS Code too? (Doesn't have to be exactly the same.)