Provide completions for associated types#784
Open
TedDriggs wants to merge 3 commits intoracer-rust:masterfrom
Open
Provide completions for associated types#784TedDriggs wants to merge 3 commits intoracer-rust:masterfrom
TedDriggs wants to merge 3 commits intoracer-rust:masterfrom
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
bkchr
approved these changes
Aug 31, 2017
Contributor
bkchr
left a comment
There was a problem hiding this comment.
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?
jwilm
reviewed
Sep 15, 2017
Collaborator
jwilm
left a comment
There was a problem hiding this comment.
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; |
Collaborator
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #775. This fix is very similar to the one for trait functions: