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/adt.rs | |
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/adt.rs')
-rw-r--r-- | crates/ra_hir/src/adt.rs | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/crates/ra_hir/src/adt.rs b/crates/ra_hir/src/adt.rs index 22bbad964..c549e2126 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, | 15 | type_ref::TypeRef, PersistentHirDatabase, |
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 HirDatabase) -> Arc<VariantData> { | 36 | pub(crate) fn variant_data(&self, db: &impl PersistentHirDatabase) -> 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,7 +52,10 @@ impl StructData { | |||
52 | StructData { name, variant_data } | 52 | StructData { name, variant_data } |
53 | } | 53 | } |
54 | 54 | ||
55 | pub(crate) fn struct_data_query(db: &impl HirDatabase, struct_: Struct) -> Arc<StructData> { | 55 | pub(crate) fn struct_data_query( |
56 | db: &impl PersistentHirDatabase, | ||
57 | struct_: Struct, | ||
58 | ) -> Arc<StructData> { | ||
56 | let (_, struct_def) = struct_.source(db); | 59 | let (_, struct_def) = struct_.source(db); |
57 | Arc::new(StructData::new(&*struct_def)) | 60 | Arc::new(StructData::new(&*struct_def)) |
58 | } | 61 | } |
@@ -68,7 +71,7 @@ fn variants(enum_def: &ast::EnumDef) -> impl Iterator<Item = &ast::EnumVariant> | |||
68 | impl EnumVariant { | 71 | impl EnumVariant { |
69 | pub(crate) fn source_impl( | 72 | pub(crate) fn source_impl( |
70 | &self, | 73 | &self, |
71 | db: &impl HirDatabase, | 74 | db: &impl PersistentHirDatabase, |
72 | ) -> (HirFileId, TreeArc<ast::EnumVariant>) { | 75 | ) -> (HirFileId, TreeArc<ast::EnumVariant>) { |
73 | let (file_id, enum_def) = self.parent.source(db); | 76 | let (file_id, enum_def) = self.parent.source(db); |
74 | let var = variants(&*enum_def) | 77 | let var = variants(&*enum_def) |
@@ -79,7 +82,7 @@ impl EnumVariant { | |||
79 | .to_owned(); | 82 | .to_owned(); |
80 | (file_id, var) | 83 | (file_id, var) |
81 | } | 84 | } |
82 | pub(crate) fn variant_data(&self, db: &impl HirDatabase) -> Arc<VariantData> { | 85 | pub(crate) fn variant_data(&self, db: &impl PersistentHirDatabase) -> Arc<VariantData> { |
83 | db.enum_data(self.parent).variants[self.id] | 86 | db.enum_data(self.parent).variants[self.id] |
84 | .variant_data | 87 | .variant_data |
85 | .clone() | 88 | .clone() |
@@ -93,7 +96,7 @@ pub struct EnumData { | |||
93 | } | 96 | } |
94 | 97 | ||
95 | impl EnumData { | 98 | impl EnumData { |
96 | pub(crate) fn enum_data_query(db: &impl HirDatabase, e: Enum) -> Arc<EnumData> { | 99 | pub(crate) fn enum_data_query(db: &impl PersistentHirDatabase, e: Enum) -> Arc<EnumData> { |
97 | let (_file_id, enum_def) = e.source(db); | 100 | let (_file_id, enum_def) = e.source(db); |
98 | let name = enum_def.name().map(|n| n.as_name()); | 101 | let name = enum_def.name().map(|n| n.as_name()); |
99 | let variants = variants(&*enum_def) | 102 | let variants = variants(&*enum_def) |
@@ -191,7 +194,7 @@ impl VariantDef { | |||
191 | VariantDef::EnumVariant(it) => it.field(db, name), | 194 | VariantDef::EnumVariant(it) => it.field(db, name), |
192 | } | 195 | } |
193 | } | 196 | } |
194 | pub(crate) fn variant_data(self, db: &impl HirDatabase) -> Arc<VariantData> { | 197 | pub(crate) fn variant_data(self, db: &impl PersistentHirDatabase) -> Arc<VariantData> { |
195 | match self { | 198 | match self { |
196 | VariantDef::Struct(it) => it.variant_data(db), | 199 | VariantDef::Struct(it) => it.variant_data(db), |
197 | VariantDef::EnumVariant(it) => it.variant_data(db), | 200 | VariantDef::EnumVariant(it) => it.variant_data(db), |
@@ -200,7 +203,7 @@ impl VariantDef { | |||
200 | } | 203 | } |
201 | 204 | ||
202 | impl StructField { | 205 | impl StructField { |
203 | pub(crate) fn source_impl(&self, db: &impl HirDatabase) -> (HirFileId, FieldSource) { | 206 | pub(crate) fn source_impl(&self, db: &impl PersistentHirDatabase) -> (HirFileId, FieldSource) { |
204 | let var_data = self.parent.variant_data(db); | 207 | let var_data = self.parent.variant_data(db); |
205 | let fields = var_data.fields().unwrap(); | 208 | let fields = var_data.fields().unwrap(); |
206 | let ss; | 209 | let ss; |