diff options
author | Aleksey Kladov <[email protected]> | 2019-05-23 18:30:09 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-05-23 18:30:09 +0100 |
commit | 7f22f905037f4a6c15195263e9bb6bcb022d65b6 (patch) | |
tree | a9b666a25793abb1d32f6ee30e3612323c82f30f /crates | |
parent | dbd02546b9cea2a2633cd0414040980f8e4a29e1 (diff) |
kill krate_impl
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_hir/src/code_model_api.rs | 15 | ||||
-rw-r--r-- | crates/ra_hir/src/code_model_impl.rs | 1 | ||||
-rw-r--r-- | crates/ra_hir/src/code_model_impl/krate.rs | 22 |
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}; | |||
4 | use ra_syntax::{ast::self, TreeArc}; | 4 | use ra_syntax::{ast::self, TreeArc}; |
5 | 5 | ||
6 | use crate::{ | 6 | use 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 @@ | |||
1 | mod krate; // `crate` is invalid ident :( | ||
2 | mod konst; // `const` is invalid ident :( | 1 | mod konst; // `const` is invalid ident :( |
3 | mod module; | 2 | mod module; |
4 | pub(crate) mod function; | 3 | pub(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 @@ | |||
1 | use crate::{ | ||
2 | Crate, CrateDependency, AsName, Module, DefDatabase, | ||
3 | }; | ||
4 | |||
5 | impl 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 | } | ||