diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-01 14:31:23 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-01 14:31:23 +0000 |
commit | 2b5c226e86892113bcab478cdf4c9adaf1e7b2f6 (patch) | |
tree | 3904cb714292f3e1abe5081e4e516eea1b2568fa /crates/ra_hir/src/code_model_impl | |
parent | 21c593593163c22b996f7c8bffe05b9708f5b2d0 (diff) | |
parent | 4dffdcf14abe0c79f9d7a9702be77958be1f75b1 (diff) |
Merge #718
718: split HirDatabase r=matklad a=csmoe
Closes #706
Co-authored-by: csmoe <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/code_model_impl')
-rw-r--r-- | crates/ra_hir/src/code_model_impl/function.rs | 7 | ||||
-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, 22 insertions, 11 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..5b0b31b1d 100644 --- a/crates/ra_hir/src/code_model_impl/function.rs +++ b/crates/ra_hir/src/code_model_impl/function.rs | |||
@@ -5,7 +5,7 @@ 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 | expr::Body, PersistentHirDatabase, |
9 | impl_block::ImplBlock, | 9 | impl_block::ImplBlock, |
10 | }; | 10 | }; |
11 | 11 | ||
@@ -22,7 +22,10 @@ impl Function { | |||
22 | } | 22 | } |
23 | 23 | ||
24 | impl FnSignature { | 24 | impl FnSignature { |
25 | pub(crate) fn fn_signature_query(db: &impl HirDatabase, func: Function) -> Arc<FnSignature> { | 25 | pub(crate) fn fn_signature_query( |
26 | db: &impl PersistentHirDatabase, | ||
27 | func: Function, | ||
28 | ) -> Arc<FnSignature> { | ||
26 | let (_, node) = func.source(db); | 29 | let (_, node) = func.source(db); |
27 | let name = node | 30 | let name = node |
28 | .name() | 31 | .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)) |