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
Return multiple modules in parent_module
feature
#8028
Conversation
@@ -18,8 +19,7 @@ use crate::NavigationTarget; | |||
// | VS Code | **Rust Analyzer: Locate parent module** | |||
// |=== | |||
|
|||
/// This returns `Vec` because a module may be included from several places. We | |||
/// don't handle this case yet though, so the Vec has length at most one. | |||
/// This returns `Vec` because a module may be included from several places. |
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.
😭
changelog internal prepare for returning parents in the "Locate parent module" command. |
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!
pub fn to_module_def(&self, file: FileId) -> Option<Module> { | ||
self.imp.to_module_def(file).next() | ||
} | ||
|
||
pub fn to_module_defs(&self, file: FileId) -> impl Iterator<Item = Module> { |
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 the future, we should get rid of the first function. It's problematic in that it's not obvious, at the call site, that more than one result can be returned. Although, just returening a vec in call cases seems wrong as well. Rather, the caller probably wants to pass in some kind of predicate object, which is used to select the best possible module.
So, something like fn guess_module_def(file: FiledId, node: &SyntaxNode)
might make sens.
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.
Ye was thinking about that as well a bit, getting the predicate/heuristic right seems difficult
bors r=matklad |
No description provided.