aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/code_model_impl
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-01-06 17:01:49 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-01-06 17:01:49 +0000
commit0d59422b18de8dce416d792b9e7dbe9b8d5aa30a (patch)
tree2032c28d8a72b162abe9f7b8dddffef7f036b91d /crates/ra_hir/src/code_model_impl
parentcf0ce14351af03c620aca784ee2c03aad86b866e (diff)
parent8a3b489c2f57bdf8f6241e69276efa48b5ed4a98 (diff)
Merge #445
445: kill module source r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/code_model_impl')
-rw-r--r--crates/ra_hir/src/code_model_impl/krate.rs12
-rw-r--r--crates/ra_hir/src/code_model_impl/module.rs6
2 files changed, 10 insertions, 8 deletions
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 @@
1use ra_db::{CrateId, Cancelable}; 1use ra_db::{CrateId, Cancelable};
2 2
3use crate::{ 3use crate::{
4 HirFileId, Crate, CrateDependency, AsName, DefLoc, DefKind, Module, 4 HirFileId, Crate, CrateDependency, AsName, DefLoc, DefKind, Module, SourceItemId,
5 db::HirDatabase, 5 db::HirDatabase,
6}; 6};
7 7
@@ -27,15 +27,17 @@ impl Crate {
27 let file_id = HirFileId::from(file_id); 27 let file_id = HirFileId::from(file_id);
28 let module_tree = db.module_tree(source_root_id)?; 28 let module_tree = db.module_tree(source_root_id)?;
29 // FIXME: teach module tree about crate roots instead of guessing 29 // FIXME: teach module tree about crate roots instead of guessing
30 let (module_id, _) = ctry!(module_tree 30 let source = SourceItemId {
31 .modules_with_sources() 31 file_id,
32 .find(|(_, src)| src.file_id() == file_id)); 32 item_id: None,
33 };
34 let module_id = ctry!(module_tree.find_module_by_source(source));
33 35
34 let def_loc = DefLoc { 36 let def_loc = DefLoc {
35 kind: DefKind::Module, 37 kind: DefKind::Module,
36 source_root_id, 38 source_root_id,
37 module_id, 39 module_id,
38 source_item_id: module_id.source(&module_tree).0, 40 source_item_id: module_id.source(&module_tree),
39 }; 41 };
40 let def_id = def_loc.id(db); 42 let def_id = def_loc.id(db);
41 43
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 {
22 kind: DefKind::Module, 22 kind: DefKind::Module,
23 source_root_id, 23 source_root_id,
24 module_id, 24 module_id,
25 source_item_id: module_id.source(&module_tree).0, 25 source_item_id: module_id.source(&module_tree),
26 }; 26 };
27 let def_id = def_loc.id(db); 27 let def_id = def_loc.id(db);
28 let module = Module::new(def_id); 28 let module = Module::new(def_id);
@@ -63,9 +63,9 @@ impl Module {
63 let file_id = link 63 let file_id = link
64 .owner(&module_tree) 64 .owner(&module_tree)
65 .source(&module_tree) 65 .source(&module_tree)
66 .file_id() 66 .file_id
67 .as_original_file(); 67 .as_original_file();
68 let src = link.bind_source(&module_tree, db); 68 let src = link.source(&module_tree, db);
69 Ok(Some((file_id, src))) 69 Ok(Some((file_id, src)))
70 } 70 }
71 71