diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-03-23 12:44:47 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-03-23 12:44:47 +0000 |
commit | bce55c749a65f268a156606fa7e8dc15821ee631 (patch) | |
tree | 2b9ba6289fc865889775dab7c6b029faea7161ab /crates/ra_hir/src/adt.rs | |
parent | 331220fee2c8c6d9f6e87c371ab101baace205dc (diff) | |
parent | 3f0cf6ebe1a42c3a38f3ab8a7b2e10110ed91ee1 (diff) |
Merge #1026
1026: rename persistent hir database -> def database r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/adt.rs')
-rw-r--r-- | crates/ra_hir/src/adt.rs | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/crates/ra_hir/src/adt.rs b/crates/ra_hir/src/adt.rs index 325f1d7b6..78ea8976b 100644 --- a/crates/ra_hir/src/adt.rs +++ b/crates/ra_hir/src/adt.rs | |||
@@ -12,7 +12,7 @@ use ra_syntax::{ | |||
12 | use crate::{ | 12 | use crate::{ |
13 | Name, AsName, Struct, Enum, EnumVariant, Crate, | 13 | Name, AsName, Struct, Enum, EnumVariant, Crate, |
14 | HirDatabase, HirFileId, StructField, FieldSource, | 14 | HirDatabase, HirFileId, StructField, FieldSource, |
15 | type_ref::TypeRef, PersistentHirDatabase, | 15 | type_ref::TypeRef, DefDatabase, |
16 | }; | 16 | }; |
17 | 17 | ||
18 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] | 18 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] |
@@ -33,7 +33,7 @@ impl AdtDef { | |||
33 | } | 33 | } |
34 | 34 | ||
35 | impl Struct { | 35 | impl Struct { |
36 | pub(crate) fn variant_data(&self, db: &impl PersistentHirDatabase) -> Arc<VariantData> { | 36 | pub(crate) fn variant_data(&self, db: &impl DefDatabase) -> Arc<VariantData> { |
37 | db.struct_data((*self).into()).variant_data.clone() | 37 | db.struct_data((*self).into()).variant_data.clone() |
38 | } | 38 | } |
39 | } | 39 | } |
@@ -52,10 +52,7 @@ impl StructData { | |||
52 | StructData { name, variant_data } | 52 | StructData { name, variant_data } |
53 | } | 53 | } |
54 | 54 | ||
55 | pub(crate) fn struct_data_query( | 55 | pub(crate) fn struct_data_query(db: &impl DefDatabase, struct_: Struct) -> Arc<StructData> { |
56 | db: &impl PersistentHirDatabase, | ||
57 | struct_: Struct, | ||
58 | ) -> Arc<StructData> { | ||
59 | let (_, struct_def) = struct_.source(db); | 56 | let (_, struct_def) = struct_.source(db); |
60 | Arc::new(StructData::new(&*struct_def)) | 57 | Arc::new(StructData::new(&*struct_def)) |
61 | } | 58 | } |
@@ -68,7 +65,7 @@ fn variants(enum_def: &ast::EnumDef) -> impl Iterator<Item = &ast::EnumVariant> | |||
68 | impl EnumVariant { | 65 | impl EnumVariant { |
69 | pub(crate) fn source_impl( | 66 | pub(crate) fn source_impl( |
70 | &self, | 67 | &self, |
71 | db: &impl PersistentHirDatabase, | 68 | db: &impl DefDatabase, |
72 | ) -> (HirFileId, TreeArc<ast::EnumVariant>) { | 69 | ) -> (HirFileId, TreeArc<ast::EnumVariant>) { |
73 | let (file_id, enum_def) = self.parent.source(db); | 70 | let (file_id, enum_def) = self.parent.source(db); |
74 | let var = variants(&*enum_def) | 71 | let var = variants(&*enum_def) |
@@ -79,7 +76,7 @@ impl EnumVariant { | |||
79 | .to_owned(); | 76 | .to_owned(); |
80 | (file_id, var) | 77 | (file_id, var) |
81 | } | 78 | } |
82 | pub(crate) fn variant_data(&self, db: &impl PersistentHirDatabase) -> Arc<VariantData> { | 79 | pub(crate) fn variant_data(&self, db: &impl DefDatabase) -> Arc<VariantData> { |
83 | db.enum_data(self.parent).variants[self.id].variant_data.clone() | 80 | db.enum_data(self.parent).variants[self.id].variant_data.clone() |
84 | } | 81 | } |
85 | } | 82 | } |
@@ -91,7 +88,7 @@ pub struct EnumData { | |||
91 | } | 88 | } |
92 | 89 | ||
93 | impl EnumData { | 90 | impl EnumData { |
94 | pub(crate) fn enum_data_query(db: &impl PersistentHirDatabase, e: Enum) -> Arc<EnumData> { | 91 | pub(crate) fn enum_data_query(db: &impl DefDatabase, e: Enum) -> Arc<EnumData> { |
95 | let (_file_id, enum_def) = e.source(db); | 92 | let (_file_id, enum_def) = e.source(db); |
96 | let name = enum_def.name().map(|n| n.as_name()); | 93 | let name = enum_def.name().map(|n| n.as_name()); |
97 | let variants = variants(&*enum_def) | 94 | let variants = variants(&*enum_def) |
@@ -189,7 +186,7 @@ impl VariantDef { | |||
189 | VariantDef::EnumVariant(it) => it.field(db, name), | 186 | VariantDef::EnumVariant(it) => it.field(db, name), |
190 | } | 187 | } |
191 | } | 188 | } |
192 | pub(crate) fn variant_data(self, db: &impl PersistentHirDatabase) -> Arc<VariantData> { | 189 | pub(crate) fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> { |
193 | match self { | 190 | match self { |
194 | VariantDef::Struct(it) => it.variant_data(db), | 191 | VariantDef::Struct(it) => it.variant_data(db), |
195 | VariantDef::EnumVariant(it) => it.variant_data(db), | 192 | VariantDef::EnumVariant(it) => it.variant_data(db), |
@@ -198,7 +195,7 @@ impl VariantDef { | |||
198 | } | 195 | } |
199 | 196 | ||
200 | impl StructField { | 197 | impl StructField { |
201 | pub(crate) fn source_impl(&self, db: &impl PersistentHirDatabase) -> (HirFileId, FieldSource) { | 198 | pub(crate) fn source_impl(&self, db: &impl DefDatabase) -> (HirFileId, FieldSource) { |
202 | let var_data = self.parent.variant_data(db); | 199 | let var_data = self.parent.variant_data(db); |
203 | let fields = var_data.fields().unwrap(); | 200 | let fields = var_data.fields().unwrap(); |
204 | let ss; | 201 | let ss; |