-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Support "get type of the expression" functionality #389
Comments
I try this, before #388. |
@h-michael I am not sure: we already have So we only need to expose that to the LSP layer, by writing appropriate handlers in ra_lsp_server crate.
|
@matklad |
I think we should prefer to show docs over showing the type. |
What you said is that we show type by |
No, I mean the logic should be as roughly follows:
|
I see, thanks for explaining a detail! |
This should be handled in |
I also think it is better. |
But I think if |
Blocked on upstream: microsoft/language-server-protocol#377 |
@matklad Can I take a jab at implementing this? |
@alexfertel sure! |
@alexfertel it's yours. |
Hey, guys, sorry to be this slow, I haven't had a lot of time and there's a lot of reading (both code and not code) to be done, so I can tackle this implementation. I promise that I will eventually submit a PR, hopefully in the next few days. |
No rush, it takes time to get familiar with unknown codebases. If you got questions about things you don't understand or which seem unclear feel free to hit up the zulip channel. |
It's very useful to be able to get the type of the expression at the cursor position. The way this feature should ideally work is that you place the cursor on the target expression, like
1 +<|> 2.foo()
, then press "extend selection" several times until you select the the whole expression, and then invoke "show type".Unfortunatelly, LSP does not have an API for this sort of functionality yet, so we need to hack it a bit.
I propose the following plan:
type_of_expression(&self, FileRange) -> Option<String>
API on theAnalysis
textDocument/hover
on top of it. Hover talks about positions, not ranges, so the implementation should first find anast::Expr
at the given offset (usingfind_node_at_offfset
) and then invoketype_of_expression
.ra-lsp/typeOfExpression
which sends a range instead of a single offset.See this issue for the implementation tips.
The text was updated successfully, but these errors were encountered: