-
Notifications
You must be signed in to change notification settings - Fork 279
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
Add get-type command #730
base: master
Are you sure you want to change the base?
Add get-type command #730
Conversation
The `get-type` command (requested in racer-rust#620) takes a line and character number which point to a complete identifier in the input text. The command will then attempt to determine the concrete type of that identifier.
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.
Hey this is really cool! Thanks 😄
Looks good overall, but had a few questions about match strings/determined types.
"; | ||
|
||
let got = get_type(src, None); | ||
assert_eq!("Option", got.matchstr); |
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.
hmm, can we not determine that it's an Option<usize>
?
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.
We don't put generic types into the matchstr
property today; they're in the generic_types
array instead. I could try and do something to push that data into matchstr
but I'm not sure which approach would be better for tooling authors.
"#; | ||
|
||
let got = get_type(src, None); | ||
assert_eq!("str", got.matchstr); |
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.
Shouldn't this be &str
? name
is a reference type (ie, a pointer).
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.
See this comment
Is there any reason this PR hasn't been merged? |
@MadRubicant |
I don't specifically need this feature; I was hoping it would let me hack together completion for closures. I cloned the branch to test it, and trying to get the type of a closure argument causes a panic |
@MadRubicant |
I would love to have this feature. I have to resort to hacks to get the type of a variable in neovim now. |
@shinzui |
Hi @kngwyu, has there been any progress on this feature? I got super excited when I saw this PR, and then I realized how old it was. I would be happy to try to rebase/rewrite it on top of master, if nobody else is working on this and if this functionality is not supplied somewhere else (e.g. rustc). |
@Baranowski |
The
get-type
command (requested in #620) takes a line and character number which point to a complete identifier in the input text. The command will then attempt to determine the concrete type of that identifier.Note that this also includes the travis updates from #728; this was necessary to make CI pass.