-
Notifications
You must be signed in to change notification settings - Fork 278
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
Provide completions for associated types #784
base: master
Are you sure you want to change the base?
Conversation
This fix is very similar to the one for trait functions: 1. Look to see if cursor is after a declaration keyword 2. If so, try to find the enclosing trait 3. If trait found, look for trait items of the right type
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.
LGTM. Maybe adding another test like the following:
trait TestTrait {
type ErrorOne;
type ErrorTwo;
}
struct Test;
impl Trait for Test {
type Error~
}
And then use get_all_completions to check that both are returned?
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.
In addition to the two tests you have here, should there be a test which checks autocomplete works in incomplete code snippets? For instance,
impl IntoIterator for Foo {
type I~
}
Would provide two completions Item
and IntoIter
.
if txt_matches(search_type, &format!("type {}", searchstr), signature) { | ||
debug!("found associated type starting |{}| |{}|", searchstr, blob); | ||
// TODO: parse this properly | ||
let start = blob.find(&format!("type {}", searchstr)).unwrap() + 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.
Since format!
allocates, is kind of expensive, and this same string is generated in two places, it should probably be made a variable binding above.
Fixes #775. This fix is very similar to the one for trait functions: