aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/code_model_api.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/code_model_api.rs')
-rw-r--r--crates/ra_hir/src/code_model_api.rs15
1 files changed, 12 insertions, 3 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 {