fix go to parent module

This commit is contained in:
Aleksey Kladov 2019-01-13 21:56:20 +03:00
parent 4209022e5b
commit 077a02271c
2 changed files with 21 additions and 2 deletions

View file

@ -89,6 +89,25 @@ impl NavigationTarget {
Ok(res)
}
pub(crate) fn from_module_to_decl(
db: &RootDatabase,
module: hir::Module,
) -> Cancelable<NavigationTarget> {
let name = module
.name(db)?
.map(|it| it.to_string().into())
.unwrap_or_default();
if let Some((file_id, source)) = module.declaration_source(db)? {
return Ok(NavigationTarget::from_syntax(
file_id,
name,
None,
source.syntax(),
));
}
NavigationTarget::from_module(db, module)
}
// TODO once Def::Item is gone, this should be able to always return a NavigationTarget
pub(crate) fn from_def(db: &RootDatabase, def: Def) -> Cancelable<Option<NavigationTarget>> {
let res = match def {