From 8a3b489c2f57bdf8f6241e69276efa48b5ed4a98 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 6 Jan 2019 19:58:10 +0300 Subject: kill module source --- crates/ra_hir/src/code_model_impl/krate.rs | 12 +++++++----- crates/ra_hir/src/code_model_impl/module.rs | 6 +++--- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'crates/ra_hir/src/code_model_impl') diff --git a/crates/ra_hir/src/code_model_impl/krate.rs b/crates/ra_hir/src/code_model_impl/krate.rs index 591a81597..3275eafed 100644 --- a/crates/ra_hir/src/code_model_impl/krate.rs +++ b/crates/ra_hir/src/code_model_impl/krate.rs @@ -1,7 +1,7 @@ use ra_db::{CrateId, Cancelable}; use crate::{ - HirFileId, Crate, CrateDependency, AsName, DefLoc, DefKind, Module, + HirFileId, Crate, CrateDependency, AsName, DefLoc, DefKind, Module, SourceItemId, db::HirDatabase, }; @@ -27,15 +27,17 @@ impl Crate { let file_id = HirFileId::from(file_id); let module_tree = db.module_tree(source_root_id)?; // FIXME: teach module tree about crate roots instead of guessing - let (module_id, _) = ctry!(module_tree - .modules_with_sources() - .find(|(_, src)| src.file_id() == file_id)); + let source = SourceItemId { + file_id, + item_id: None, + }; + let module_id = ctry!(module_tree.find_module_by_source(source)); let def_loc = DefLoc { kind: DefKind::Module, source_root_id, module_id, - source_item_id: module_id.source(&module_tree).0, + source_item_id: module_id.source(&module_tree), }; let def_id = def_loc.id(db); diff --git a/crates/ra_hir/src/code_model_impl/module.rs b/crates/ra_hir/src/code_model_impl/module.rs index 02078f188..eb35779f1 100644 --- a/crates/ra_hir/src/code_model_impl/module.rs +++ b/crates/ra_hir/src/code_model_impl/module.rs @@ -22,7 +22,7 @@ impl Module { kind: DefKind::Module, source_root_id, module_id, - source_item_id: module_id.source(&module_tree).0, + source_item_id: module_id.source(&module_tree), }; let def_id = def_loc.id(db); let module = Module::new(def_id); @@ -63,9 +63,9 @@ impl Module { let file_id = link .owner(&module_tree) .source(&module_tree) - .file_id() + .file_id .as_original_file(); - let src = link.bind_source(&module_tree, db); + let src = link.source(&module_tree, db); Ok(Some((file_id, src))) } -- cgit v1.2.3