Return multiple modules in parent_module

This commit is contained in:
Lukas Wirth 2021-03-15 14:51:20 +01:00
parent f2c39d0cdf
commit 2e3c156b0e
5 changed files with 76 additions and 35 deletions

View file

@ -259,6 +259,10 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
}
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> {
self.imp.to_module_def(file)
}
@ -537,8 +541,8 @@ impl<'db> SemanticsImpl<'db> {
f(&mut ctx)
}
fn to_module_def(&self, file: FileId) -> Option<Module> {
self.with_ctx(|ctx| ctx.file_to_def(file)).map(Module::from)
fn to_module_def(&self, file: FileId) -> impl Iterator<Item = Module> {
self.with_ctx(|ctx| ctx.file_to_def(file)).into_iter().map(Module::from)
}
fn scope(&self, node: &SyntaxNode) -> SemanticsScope<'db> {