diff options
author | Aleksey Kladov <[email protected]> | 2019-03-23 12:37:04 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-03-23 12:44:24 +0000 |
commit | 3f0cf6ebe1a42c3a38f3ab8a7b2e10110ed91ee1 (patch) | |
tree | 2b9ba6289fc865889775dab7c6b029faea7161ab /crates/ra_hir/src/code_model_impl | |
parent | 331220fee2c8c6d9f6e87c371ab101baace205dc (diff) |
rename persistent hir database -> def database
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/konst.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir/src/code_model_impl/krate.rs | 9 | ||||
-rw-r--r-- | crates/ra_hir/src/code_model_impl/module.rs | 15 |
4 files changed, 14 insertions, 23 deletions
diff --git a/crates/ra_hir/src/code_model_impl/function.rs b/crates/ra_hir/src/code_model_impl/function.rs index c1654b069..334cb302b 100644 --- a/crates/ra_hir/src/code_model_impl/function.rs +++ b/crates/ra_hir/src/code_model_impl/function.rs | |||
@@ -5,14 +5,11 @@ use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner}; | |||
5 | use crate::{ | 5 | use crate::{ |
6 | Name, AsName, Function, FnSignature, | 6 | Name, AsName, Function, FnSignature, |
7 | type_ref::{TypeRef, Mutability}, | 7 | type_ref::{TypeRef, Mutability}, |
8 | PersistentHirDatabase, | 8 | DefDatabase, |
9 | }; | 9 | }; |
10 | 10 | ||
11 | impl FnSignature { | 11 | impl FnSignature { |
12 | pub(crate) fn fn_signature_query( | 12 | pub(crate) fn fn_signature_query(db: &impl DefDatabase, func: Function) -> Arc<FnSignature> { |
13 | db: &impl PersistentHirDatabase, | ||
14 | func: Function, | ||
15 | ) -> Arc<FnSignature> { | ||
16 | let (_, node) = func.source(db); | 13 | let (_, node) = func.source(db); |
17 | let name = node.name().map(|n| n.as_name()).unwrap_or_else(Name::missing); | 14 | let name = node.name().map(|n| n.as_name()).unwrap_or_else(Name::missing); |
18 | let mut params = Vec::new(); | 15 | let mut params = Vec::new(); |
diff --git a/crates/ra_hir/src/code_model_impl/konst.rs b/crates/ra_hir/src/code_model_impl/konst.rs index 8b861a81f..db4e5ce5c 100644 --- a/crates/ra_hir/src/code_model_impl/konst.rs +++ b/crates/ra_hir/src/code_model_impl/konst.rs | |||
@@ -5,7 +5,7 @@ use ra_syntax::ast::{NameOwner, TypeAscriptionOwner}; | |||
5 | use crate::{ | 5 | use crate::{ |
6 | Name, AsName, Const, ConstSignature, Static, | 6 | Name, AsName, Const, ConstSignature, Static, |
7 | type_ref::{TypeRef}, | 7 | type_ref::{TypeRef}, |
8 | PersistentHirDatabase, | 8 | DefDatabase, |
9 | }; | 9 | }; |
10 | 10 | ||
11 | fn const_signature_for<N: NameOwner + TypeAscriptionOwner>(node: &N) -> Arc<ConstSignature> { | 11 | fn const_signature_for<N: NameOwner + TypeAscriptionOwner>(node: &N) -> Arc<ConstSignature> { |
@@ -17,7 +17,7 @@ fn const_signature_for<N: NameOwner + TypeAscriptionOwner>(node: &N) -> Arc<Cons | |||
17 | 17 | ||
18 | impl ConstSignature { | 18 | impl ConstSignature { |
19 | pub(crate) fn const_signature_query( | 19 | pub(crate) fn const_signature_query( |
20 | db: &impl PersistentHirDatabase, | 20 | db: &impl DefDatabase, |
21 | konst: Const, | 21 | konst: Const, |
22 | ) -> Arc<ConstSignature> { | 22 | ) -> Arc<ConstSignature> { |
23 | let (_, node) = konst.source(db); | 23 | let (_, node) = konst.source(db); |
@@ -25,7 +25,7 @@ impl ConstSignature { | |||
25 | } | 25 | } |
26 | 26 | ||
27 | pub(crate) fn static_signature_query( | 27 | pub(crate) fn static_signature_query( |
28 | db: &impl PersistentHirDatabase, | 28 | db: &impl DefDatabase, |
29 | konst: Static, | 29 | konst: Static, |
30 | ) -> Arc<ConstSignature> { | 30 | ) -> Arc<ConstSignature> { |
31 | let (_, node) = konst.source(db); | 31 | let (_, node) = konst.source(db); |
diff --git a/crates/ra_hir/src/code_model_impl/krate.rs b/crates/ra_hir/src/code_model_impl/krate.rs index cc87c6f14..914414fc3 100644 --- a/crates/ra_hir/src/code_model_impl/krate.rs +++ b/crates/ra_hir/src/code_model_impl/krate.rs | |||
@@ -1,12 +1,9 @@ | |||
1 | use crate::{ | 1 | use crate::{ |
2 | Crate, CrateDependency, AsName, Module, PersistentHirDatabase, | 2 | Crate, CrateDependency, AsName, Module, DefDatabase, |
3 | }; | 3 | }; |
4 | 4 | ||
5 | impl Crate { | 5 | impl Crate { |
6 | pub(crate) fn dependencies_impl( | 6 | pub(crate) fn dependencies_impl(&self, db: &impl DefDatabase) -> Vec<CrateDependency> { |
7 | &self, | ||
8 | db: &impl PersistentHirDatabase, | ||
9 | ) -> Vec<CrateDependency> { | ||
10 | let crate_graph = db.crate_graph(); | 7 | let crate_graph = db.crate_graph(); |
11 | crate_graph | 8 | crate_graph |
12 | .dependencies(self.crate_id) | 9 | .dependencies(self.crate_id) |
@@ -17,7 +14,7 @@ impl Crate { | |||
17 | }) | 14 | }) |
18 | .collect() | 15 | .collect() |
19 | } | 16 | } |
20 | pub(crate) fn root_module_impl(&self, db: &impl PersistentHirDatabase) -> Option<Module> { | 17 | pub(crate) fn root_module_impl(&self, db: &impl DefDatabase) -> Option<Module> { |
21 | let module_id = db.crate_def_map(*self).root(); | 18 | let module_id = db.crate_def_map(*self).root(); |
22 | let module = Module { krate: *self, module_id }; | 19 | let module = Module { krate: *self, module_id }; |
23 | Some(module) | 20 | Some(module) |
diff --git a/crates/ra_hir/src/code_model_impl/module.rs b/crates/ra_hir/src/code_model_impl/module.rs index f7d15c55e..52a33e981 100644 --- a/crates/ra_hir/src/code_model_impl/module.rs +++ b/crates/ra_hir/src/code_model_impl/module.rs | |||
@@ -4,13 +4,13 @@ use ra_syntax::{ast, SyntaxNode, TreeArc, AstNode}; | |||
4 | use crate::{ | 4 | use crate::{ |
5 | Module, ModuleSource, Problem, Name, | 5 | Module, ModuleSource, Problem, Name, |
6 | nameres::{CrateModuleId, ImportId}, | 6 | nameres::{CrateModuleId, ImportId}, |
7 | HirDatabase, PersistentHirDatabase, | 7 | HirDatabase, DefDatabase, |
8 | HirFileId, SourceItemId, | 8 | HirFileId, SourceItemId, |
9 | }; | 9 | }; |
10 | 10 | ||
11 | impl ModuleSource { | 11 | impl ModuleSource { |
12 | pub(crate) fn new( | 12 | pub(crate) fn new( |
13 | db: &impl PersistentHirDatabase, | 13 | db: &impl DefDatabase, |
14 | file_id: Option<FileId>, | 14 | file_id: Option<FileId>, |
15 | decl_id: Option<SourceItemId>, | 15 | decl_id: Option<SourceItemId>, |
16 | ) -> ModuleSource { | 16 | ) -> ModuleSource { |
@@ -49,7 +49,7 @@ impl Module { | |||
49 | 49 | ||
50 | pub(crate) fn definition_source_impl( | 50 | pub(crate) fn definition_source_impl( |
51 | &self, | 51 | &self, |
52 | db: &impl PersistentHirDatabase, | 52 | db: &impl DefDatabase, |
53 | ) -> (HirFileId, ModuleSource) { | 53 | ) -> (HirFileId, ModuleSource) { |
54 | let def_map = db.crate_def_map(self.krate); | 54 | let def_map = db.crate_def_map(self.krate); |
55 | let decl_id = def_map[self.module_id].declaration; | 55 | let decl_id = def_map[self.module_id].declaration; |
@@ -80,7 +80,7 @@ impl Module { | |||
80 | source_map.get(&source, import) | 80 | source_map.get(&source, import) |
81 | } | 81 | } |
82 | 82 | ||
83 | pub(crate) fn crate_root_impl(&self, db: &impl PersistentHirDatabase) -> Module { | 83 | pub(crate) fn crate_root_impl(&self, db: &impl DefDatabase) -> Module { |
84 | let def_map = db.crate_def_map(self.krate); | 84 | let def_map = db.crate_def_map(self.krate); |
85 | self.with_module_id(def_map.root()) | 85 | self.with_module_id(def_map.root()) |
86 | } | 86 | } |
@@ -93,10 +93,7 @@ impl Module { | |||
93 | } | 93 | } |
94 | 94 | ||
95 | /// Iterates over all child modules. | 95 | /// Iterates over all child modules. |
96 | pub(crate) fn children_impl( | 96 | pub(crate) fn children_impl(&self, db: &impl DefDatabase) -> impl Iterator<Item = Module> { |
97 | &self, | ||
98 | db: &impl PersistentHirDatabase, | ||
99 | ) -> impl Iterator<Item = Module> { | ||
100 | let def_map = db.crate_def_map(self.krate); | 97 | let def_map = db.crate_def_map(self.krate); |
101 | let children = def_map[self.module_id] | 98 | let children = def_map[self.module_id] |
102 | .children | 99 | .children |
@@ -106,7 +103,7 @@ impl Module { | |||
106 | children.into_iter() | 103 | children.into_iter() |
107 | } | 104 | } |
108 | 105 | ||
109 | pub(crate) fn parent_impl(&self, db: &impl PersistentHirDatabase) -> Option<Module> { | 106 | pub(crate) fn parent_impl(&self, db: &impl DefDatabase) -> Option<Module> { |
110 | let def_map = db.crate_def_map(self.krate); | 107 | let def_map = db.crate_def_map(self.krate); |
111 | let parent_id = def_map[self.module_id].parent?; | 108 | let parent_id = def_map[self.module_id].parent?; |
112 | Some(self.with_module_id(parent_id)) | 109 | Some(self.with_module_id(parent_id)) |