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.rs21
1 files changed, 10 insertions, 11 deletions
diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs
index 87a7195e6..b00481cd5 100644
--- a/crates/ra_hir/src/code_model_api.rs
+++ b/crates/ra_hir/src/code_model_api.rs
@@ -8,13 +8,12 @@ use crate::{
8 Name, ScopesWithSourceMap, Ty, HirFileId, 8 Name, ScopesWithSourceMap, Ty, HirFileId,
9 HirDatabase, PersistentHirDatabase, 9 HirDatabase, PersistentHirDatabase,
10 type_ref::TypeRef, 10 type_ref::TypeRef,
11 nameres::{ModuleScope, Namespace, lower::ImportId}, 11 nameres::{ModuleScope, Namespace, ImportId, CrateModuleId},
12 expr::{Body, BodySourceMap}, 12 expr::{Body, BodySourceMap},
13 ty::InferenceResult, 13 ty::InferenceResult,
14 adt::{EnumVariantId, StructFieldId, VariantDef}, 14 adt::{EnumVariantId, StructFieldId, VariantDef},
15 generics::GenericParams, 15 generics::GenericParams,
16 docs::{Documentation, Docs, docs_from_ast}, 16 docs::{Documentation, Docs, docs_from_ast},
17 module_tree::ModuleId,
18 ids::{FunctionId, StructId, EnumId, AstItemDef, ConstId, StaticId, TraitId, TypeId}, 17 ids::{FunctionId, StructId, EnumId, AstItemDef, ConstId, StaticId, TraitId, TypeId},
19 impl_block::ImplBlock, 18 impl_block::ImplBlock,
20 resolve::Resolver, 19 resolve::Resolver,
@@ -65,7 +64,7 @@ impl Crate {
65#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 64#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
66pub struct Module { 65pub struct Module {
67 pub(crate) krate: Crate, 66 pub(crate) krate: Crate,
68 pub(crate) module_id: ModuleId, 67 pub(crate) module_id: CrateModuleId,
69} 68}
70 69
71/// The defs which can be visible in the module. 70/// The defs which can be visible in the module.
@@ -173,7 +172,7 @@ impl Module {
173 172
174 /// Returns a `ModuleScope`: a set of items, visible in this module. 173 /// Returns a `ModuleScope`: a set of items, visible in this module.
175 pub fn scope(&self, db: &impl HirDatabase) -> ModuleScope { 174 pub fn scope(&self, db: &impl HirDatabase) -> ModuleScope {
176 db.item_map(self.krate)[self.module_id].clone() 175 db.crate_def_map(self.krate)[self.module_id].scope.clone()
177 } 176 }
178 177
179 pub fn problems(&self, db: &impl HirDatabase) -> Vec<(TreeArc<SyntaxNode>, Problem)> { 178 pub fn problems(&self, db: &impl HirDatabase) -> Vec<(TreeArc<SyntaxNode>, Problem)> {
@@ -181,16 +180,16 @@ impl Module {
181 } 180 }
182 181
183 pub fn resolver(&self, db: &impl HirDatabase) -> Resolver { 182 pub fn resolver(&self, db: &impl HirDatabase) -> Resolver {
184 let item_map = db.item_map(self.krate); 183 let def_map = db.crate_def_map(self.krate);
185 Resolver::default().push_module_scope(item_map, *self) 184 Resolver::default().push_module_scope(def_map, self.module_id)
186 } 185 }
187 186
188 pub fn declarations(self, db: &impl HirDatabase) -> Vec<ModuleDef> { 187 pub fn declarations(self, db: &impl HirDatabase) -> Vec<ModuleDef> {
189 let lowered_module = db.lower_module(self); 188 let def_map = db.crate_def_map(self.krate);
190 lowered_module 189 def_map[self.module_id]
191 .declarations 190 .scope
192 .values() 191 .entries()
193 .cloned() 192 .filter_map(|(_name, res)| if res.import.is_none() { Some(res.def) } else { None })
194 .flat_map(|per_ns| { 193 .flat_map(|per_ns| {
195 per_ns.take_types().into_iter().chain(per_ns.take_values().into_iter()) 194 per_ns.take_types().into_iter().chain(per_ns.take_values().into_iter())
196 }) 195 })