diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-13 19:01:06 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-13 19:01:06 +0000 |
commit | fa6e4b7978621ef97446a497cfb195ed0ae04058 (patch) | |
tree | 6e9b1d619ed2f60988567b1fcbef38df60490737 /crates/ra_ide_api/src/navigation_target.rs | |
parent | d3dfafd393e1c42494af5a15e319ba884c30f9aa (diff) | |
parent | 077a02271c855841be39d4b6b45b7df14a6fc067 (diff) |
Merge #532
532: fix go to parent module r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src/navigation_target.rs')
-rw-r--r-- | crates/ra_ide_api/src/navigation_target.rs | 19 |
1 files changed, 19 insertions, 0 deletions
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 { | |||
89 | Ok(res) | 89 | Ok(res) |
90 | } | 90 | } |
91 | 91 | ||
92 | pub(crate) fn from_module_to_decl( | ||
93 | db: &RootDatabase, | ||
94 | module: hir::Module, | ||
95 | ) -> Cancelable<NavigationTarget> { | ||
96 | let name = module | ||
97 | .name(db)? | ||
98 | .map(|it| it.to_string().into()) | ||
99 | .unwrap_or_default(); | ||
100 | if let Some((file_id, source)) = module.declaration_source(db)? { | ||
101 | return Ok(NavigationTarget::from_syntax( | ||
102 | file_id, | ||
103 | name, | ||
104 | None, | ||
105 | source.syntax(), | ||
106 | )); | ||
107 | } | ||
108 | NavigationTarget::from_module(db, module) | ||
109 | } | ||
110 | |||
92 | // TODO once Def::Item is gone, this should be able to always return a NavigationTarget | 111 | // TODO once Def::Item is gone, this should be able to always return a NavigationTarget |
93 | pub(crate) fn from_def(db: &RootDatabase, def: Def) -> Cancelable<Option<NavigationTarget>> { | 112 | pub(crate) fn from_def(db: &RootDatabase, def: Def) -> Cancelable<Option<NavigationTarget>> { |
94 | let res = match def { | 113 | let res = match def { |