From 7f22f905037f4a6c15195263e9bb6bcb022d65b6 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 23 May 2019 20:30:09 +0300 Subject: kill krate_impl --- crates/ra_hir/src/code_model_api.rs | 15 ++++++++++++--- crates/ra_hir/src/code_model_impl.rs | 1 - crates/ra_hir/src/code_model_impl/krate.rs | 22 ---------------------- 3 files changed, 12 insertions(+), 26 deletions(-) delete mode 100644 crates/ra_hir/src/code_model_impl/krate.rs (limited to 'crates') 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}; use ra_syntax::{ast::self, TreeArc}; use crate::{ - Name, Ty, HirFileId, Either, + Name, AsName, Ty, HirFileId, Either, HirDatabase, DefDatabase, type_ref::TypeRef, nameres::{ModuleScope, Namespace, ImportId, CrateModuleId}, @@ -40,11 +40,20 @@ impl Crate { } pub fn dependencies(self, db: &impl DefDatabase) -> Vec { - self.dependencies_impl(db) + db.crate_graph() + .dependencies(self.crate_id) + .map(|dep| { + let krate = Crate { crate_id: dep.crate_id() }; + let name = dep.as_name(); + CrateDependency { krate, name } + }) + .collect() } pub fn root_module(self, db: &impl DefDatabase) -> Option { - self.root_module_impl(db) + let module_id = db.crate_def_map(self).root(); + let module = Module { krate: self, module_id }; + Some(module) } 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 @@ -mod krate; // `crate` is invalid ident :( mod konst; // `const` is invalid ident :( mod module; 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 @@ -use crate::{ - Crate, CrateDependency, AsName, Module, DefDatabase, -}; - -impl Crate { - pub(crate) fn dependencies_impl(&self, db: &impl DefDatabase) -> Vec { - let crate_graph = db.crate_graph(); - crate_graph - .dependencies(self.crate_id) - .map(|dep| { - let krate = Crate { crate_id: dep.crate_id() }; - let name = dep.as_name(); - CrateDependency { krate, name } - }) - .collect() - } - pub(crate) fn root_module_impl(&self, db: &impl DefDatabase) -> Option { - let module_id = db.crate_def_map(*self).root(); - let module = Module { krate: *self, module_id }; - Some(module) - } -} -- cgit v1.2.3