aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/src/code_model_api.rs15
-rw-r--r--crates/ra_hir/src/code_model_impl.rs1
-rw-r--r--crates/ra_hir/src/code_model_impl/krate.rs22
3 files changed, 12 insertions, 26 deletions
diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs
index e4089afe7..637ebb7ec 100644
--- a/crates/ra_hir/src/code_model_api.rs
+++ b/crates/ra_hir/src/code_model_api.rs
@@ -4,7 +4,7 @@ use ra_db::{CrateId, SourceRootId, Edition};
4use ra_syntax::{ast::self, TreeArc}; 4use ra_syntax::{ast::self, TreeArc};
5 5
6use crate::{ 6use crate::{
7 Name, Ty, HirFileId, Either, 7 Name, AsName, Ty, HirFileId, Either,
8 HirDatabase, DefDatabase, 8 HirDatabase, DefDatabase,
9 type_ref::TypeRef, 9 type_ref::TypeRef,
10 nameres::{ModuleScope, Namespace, ImportId, CrateModuleId}, 10 nameres::{ModuleScope, Namespace, ImportId, CrateModuleId},
@@ -40,11 +40,20 @@ impl Crate {
40 } 40 }
41 41
42 pub fn dependencies(self, db: &impl DefDatabase) -> Vec<CrateDependency> { 42 pub fn dependencies(self, db: &impl DefDatabase) -> Vec<CrateDependency> {
43 self.dependencies_impl(db) 43 db.crate_graph()
44 .dependencies(self.crate_id)
45 .map(|dep| {
46 let krate = Crate { crate_id: dep.crate_id() };
47 let name = dep.as_name();
48 CrateDependency { krate, name }
49 })
50 .collect()
44 } 51 }
45 52
46 pub fn root_module(self, db: &impl DefDatabase) -> Option<Module> { 53 pub fn root_module(self, db: &impl DefDatabase) -> Option<Module> {
47 self.root_module_impl(db) 54 let module_id = db.crate_def_map(self).root();
55 let module = Module { krate: self, module_id };
56 Some(module)
48 } 57 }
49 58
50 pub fn edition(self, db: &impl DefDatabase) -> Edition { 59 pub fn edition(self, db: &impl DefDatabase) -> Edition {
diff --git a/crates/ra_hir/src/code_model_impl.rs b/crates/ra_hir/src/code_model_impl.rs
index 24df9a113..991533b5b 100644
--- a/crates/ra_hir/src/code_model_impl.rs
+++ b/crates/ra_hir/src/code_model_impl.rs
@@ -1,4 +1,3 @@
1mod krate; // `crate` is invalid ident :(
2mod konst; // `const` is invalid ident :( 1mod konst; // `const` is invalid ident :(
3mod module; 2mod module;
4pub(crate) mod function; 3pub(crate) mod function;
diff --git a/crates/ra_hir/src/code_model_impl/krate.rs b/crates/ra_hir/src/code_model_impl/krate.rs
deleted file mode 100644
index 914414fc3..000000000
--- a/crates/ra_hir/src/code_model_impl/krate.rs
+++ /dev/null
@@ -1,22 +0,0 @@
1use crate::{
2 Crate, CrateDependency, AsName, Module, DefDatabase,
3};
4
5impl Crate {
6 pub(crate) fn dependencies_impl(&self, db: &impl DefDatabase) -> Vec<CrateDependency> {
7 let crate_graph = db.crate_graph();
8 crate_graph
9 .dependencies(self.crate_id)
10 .map(|dep| {
11 let krate = Crate { crate_id: dep.crate_id() };
12 let name = dep.as_name();
13 CrateDependency { krate, name }
14 })
15 .collect()
16 }
17 pub(crate) fn root_module_impl(&self, db: &impl DefDatabase) -> Option<Module> {
18 let module_id = db.crate_def_map(*self).root();
19 let module = Module { krate: *self, module_id };
20 Some(module)
21 }
22}