diff options
Diffstat (limited to 'crates/ra_hir/src/code_model_impl')
-rw-r--r-- | crates/ra_hir/src/code_model_impl/function.rs | 11 | ||||
-rw-r--r-- | crates/ra_hir/src/code_model_impl/krate.rs | 10 | ||||
-rw-r--r-- | crates/ra_hir/src/code_model_impl/module.rs | 16 |
3 files changed, 23 insertions, 14 deletions
diff --git a/crates/ra_hir/src/code_model_impl/function.rs b/crates/ra_hir/src/code_model_impl/function.rs index 422643996..8326c02c7 100644 --- a/crates/ra_hir/src/code_model_impl/function.rs +++ b/crates/ra_hir/src/code_model_impl/function.rs | |||
@@ -5,14 +5,12 @@ use ra_syntax::ast::{self, NameOwner}; | |||
5 | use crate::{ | 5 | use crate::{ |
6 | HirDatabase, Name, AsName, Function, FnSignature, | 6 | HirDatabase, Name, AsName, Function, FnSignature, |
7 | type_ref::{TypeRef, Mutability}, | 7 | type_ref::{TypeRef, Mutability}, |
8 | expr::Body, | 8 | PersistentHirDatabase, |
9 | impl_block::ImplBlock, | 9 | impl_block::ImplBlock, |
10 | }; | 10 | }; |
11 | 11 | ||
12 | impl Function { | 12 | impl Function { |
13 | pub(crate) fn body(&self, db: &impl HirDatabase) -> Arc<Body> { | 13 | // TODO impl_block should probably also be part of the code model API? |
14 | db.body_hir(*self) | ||
15 | } | ||
16 | 14 | ||
17 | /// The containing impl block, if this is a method. | 15 | /// The containing impl block, if this is a method. |
18 | pub(crate) fn impl_block(&self, db: &impl HirDatabase) -> Option<ImplBlock> { | 16 | pub(crate) fn impl_block(&self, db: &impl HirDatabase) -> Option<ImplBlock> { |
@@ -22,7 +20,10 @@ impl Function { | |||
22 | } | 20 | } |
23 | 21 | ||
24 | impl FnSignature { | 22 | impl FnSignature { |
25 | pub(crate) fn fn_signature_query(db: &impl HirDatabase, func: Function) -> Arc<FnSignature> { | 23 | pub(crate) fn fn_signature_query( |
24 | db: &impl PersistentHirDatabase, | ||
25 | func: Function, | ||
26 | ) -> Arc<FnSignature> { | ||
26 | let (_, node) = func.source(db); | 27 | let (_, node) = func.source(db); |
27 | let name = node | 28 | let name = node |
28 | .name() | 29 | .name() |
diff --git a/crates/ra_hir/src/code_model_impl/krate.rs b/crates/ra_hir/src/code_model_impl/krate.rs index 86f29d959..1517434b8 100644 --- a/crates/ra_hir/src/code_model_impl/krate.rs +++ b/crates/ra_hir/src/code_model_impl/krate.rs | |||
@@ -1,10 +1,12 @@ | |||
1 | use crate::{ | 1 | use crate::{ |
2 | Crate, CrateDependency, AsName, Module, | 2 | Crate, CrateDependency, AsName, Module, PersistentHirDatabase, |
3 | db::HirDatabase, | ||
4 | }; | 3 | }; |
5 | 4 | ||
6 | impl Crate { | 5 | impl Crate { |
7 | pub(crate) fn dependencies_impl(&self, db: &impl HirDatabase) -> Vec<CrateDependency> { | 6 | pub(crate) fn dependencies_impl( |
7 | &self, | ||
8 | db: &impl PersistentHirDatabase, | ||
9 | ) -> Vec<CrateDependency> { | ||
8 | let crate_graph = db.crate_graph(); | 10 | let crate_graph = db.crate_graph(); |
9 | crate_graph | 11 | crate_graph |
10 | .dependencies(self.crate_id) | 12 | .dependencies(self.crate_id) |
@@ -17,7 +19,7 @@ impl Crate { | |||
17 | }) | 19 | }) |
18 | .collect() | 20 | .collect() |
19 | } | 21 | } |
20 | pub(crate) fn root_module_impl(&self, db: &impl HirDatabase) -> Option<Module> { | 22 | pub(crate) fn root_module_impl(&self, db: &impl PersistentHirDatabase) -> Option<Module> { |
21 | let module_tree = db.module_tree(*self); | 23 | let module_tree = db.module_tree(*self); |
22 | let module_id = module_tree.modules().next()?; | 24 | let module_id = module_tree.modules().next()?; |
23 | 25 | ||
diff --git a/crates/ra_hir/src/code_model_impl/module.rs b/crates/ra_hir/src/code_model_impl/module.rs index 4a3901b8b..f487b8532 100644 --- a/crates/ra_hir/src/code_model_impl/module.rs +++ b/crates/ra_hir/src/code_model_impl/module.rs | |||
@@ -7,7 +7,7 @@ use crate::{ | |||
7 | module_tree::ModuleId, | 7 | module_tree::ModuleId, |
8 | impl_block::ImplId, | 8 | impl_block::ImplId, |
9 | nameres::{lower::ImportId}, | 9 | nameres::{lower::ImportId}, |
10 | db::HirDatabase, | 10 | HirDatabase, PersistentHirDatabase, |
11 | }; | 11 | }; |
12 | 12 | ||
13 | impl Module { | 13 | impl Module { |
@@ -24,7 +24,10 @@ impl Module { | |||
24 | Some(link.name(&module_tree).clone()) | 24 | Some(link.name(&module_tree).clone()) |
25 | } | 25 | } |
26 | 26 | ||
27 | pub(crate) fn definition_source_impl(&self, db: &impl HirDatabase) -> (FileId, ModuleSource) { | 27 | pub(crate) fn definition_source_impl( |
28 | &self, | ||
29 | db: &impl PersistentHirDatabase, | ||
30 | ) -> (FileId, ModuleSource) { | ||
28 | let module_tree = db.module_tree(self.krate); | 31 | let module_tree = db.module_tree(self.krate); |
29 | let file_id = self.module_id.file_id(&module_tree); | 32 | let file_id = self.module_id.file_id(&module_tree); |
30 | let decl_id = self.module_id.decl_id(&module_tree); | 33 | let decl_id = self.module_id.decl_id(&module_tree); |
@@ -67,7 +70,7 @@ impl Module { | |||
67 | source_map.get(&source, impl_id) | 70 | source_map.get(&source, impl_id) |
68 | } | 71 | } |
69 | 72 | ||
70 | pub(crate) fn crate_root_impl(&self, db: &impl HirDatabase) -> Module { | 73 | pub(crate) fn crate_root_impl(&self, db: &impl PersistentHirDatabase) -> Module { |
71 | let module_tree = db.module_tree(self.krate); | 74 | let module_tree = db.module_tree(self.krate); |
72 | let module_id = self.module_id.crate_root(&module_tree); | 75 | let module_id = self.module_id.crate_root(&module_tree); |
73 | self.with_module_id(module_id) | 76 | self.with_module_id(module_id) |
@@ -81,7 +84,10 @@ impl Module { | |||
81 | } | 84 | } |
82 | 85 | ||
83 | /// Iterates over all child modules. | 86 | /// Iterates over all child modules. |
84 | pub(crate) fn children_impl(&self, db: &impl HirDatabase) -> impl Iterator<Item = Module> { | 87 | pub(crate) fn children_impl( |
88 | &self, | ||
89 | db: &impl PersistentHirDatabase, | ||
90 | ) -> impl Iterator<Item = Module> { | ||
85 | let module_tree = db.module_tree(self.krate); | 91 | let module_tree = db.module_tree(self.krate); |
86 | let children = self | 92 | let children = self |
87 | .module_id | 93 | .module_id |
@@ -91,7 +97,7 @@ impl Module { | |||
91 | children.into_iter() | 97 | children.into_iter() |
92 | } | 98 | } |
93 | 99 | ||
94 | pub(crate) fn parent_impl(&self, db: &impl HirDatabase) -> Option<Module> { | 100 | pub(crate) fn parent_impl(&self, db: &impl PersistentHirDatabase) -> Option<Module> { |
95 | let module_tree = db.module_tree(self.krate); | 101 | let module_tree = db.module_tree(self.krate); |
96 | let parent_id = self.module_id.parent(&module_tree)?; | 102 | let parent_id = self.module_id.parent(&module_tree)?; |
97 | Some(self.with_module_id(parent_id)) | 103 | Some(self.with_module_id(parent_id)) |