From 077a02271c855841be39d4b6b45b7df14a6fc067 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 13 Jan 2019 21:56:20 +0300 Subject: fix go to parent module --- crates/ra_ide_api/src/navigation_target.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'crates/ra_ide_api/src/navigation_target.rs') diff --git a/crates/ra_ide_api/src/navigation_target.rs b/crates/ra_ide_api/src/navigation_target.rs index b0d0a3e8b..230d0f67a 100644 --- a/crates/ra_ide_api/src/navigation_target.rs +++ b/crates/ra_ide_api/src/navigation_target.rs @@ -89,6 +89,25 @@ impl NavigationTarget { Ok(res) } + pub(crate) fn from_module_to_decl( + db: &RootDatabase, + module: hir::Module, + ) -> Cancelable { + 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> { let res = match def { -- cgit v1.2.3