aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/parent_module.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src/parent_module.rs')
-rw-r--r--crates/ra_ide_api/src/parent_module.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/crates/ra_ide_api/src/parent_module.rs b/crates/ra_ide_api/src/parent_module.rs
index 7d5f9ea2c..3668da8d7 100644
--- a/crates/ra_ide_api/src/parent_module.rs
+++ b/crates/ra_ide_api/src/parent_module.rs
@@ -5,7 +5,11 @@ use crate::{db::RootDatabase, NavigationTarget};
5/// This returns `Vec` because a module may be included from several places. We 5/// This returns `Vec` because a module may be included from several places. We
6/// don't handle this case yet though, so the Vec has length at most one. 6/// don't handle this case yet though, so the Vec has length at most one.
7pub(crate) fn parent_module(db: &RootDatabase, position: FilePosition) -> Vec<NavigationTarget> { 7pub(crate) fn parent_module(db: &RootDatabase, position: FilePosition) -> Vec<NavigationTarget> {
8 let module = match hir::source_binder::module_from_position(db, position) { 8 let src = hir::ModuleSource::from_position(db, position);
9 let module = match hir::Module::from_definition(
10 db,
11 hir::Source { file_id: position.file_id.into(), ast: src },
12 ) {
9 None => return Vec::new(), 13 None => return Vec::new(),
10 Some(it) => it, 14 Some(it) => it,
11 }; 15 };
@@ -15,10 +19,12 @@ pub(crate) fn parent_module(db: &RootDatabase, position: FilePosition) -> Vec<Na
15 19
16/// Returns `Vec` for the same reason as `parent_module` 20/// Returns `Vec` for the same reason as `parent_module`
17pub(crate) fn crate_for(db: &RootDatabase, file_id: FileId) -> Vec<CrateId> { 21pub(crate) fn crate_for(db: &RootDatabase, file_id: FileId) -> Vec<CrateId> {
18 let module = match hir::source_binder::module_from_file_id(db, file_id) { 22 let src = hir::ModuleSource::from_file_id(db, file_id);
19 Some(it) => it, 23 let module =
20 None => return Vec::new(), 24 match hir::Module::from_definition(db, hir::Source { file_id: file_id.into(), ast: src }) {
21 }; 25 Some(it) => it,
26 None => return Vec::new(),
27 };
22 let krate = match module.krate(db) { 28 let krate = match module.krate(db) {
23 Some(it) => it, 29 Some(it) => it,
24 None => return Vec::new(), 30 None => return Vec::new(),