diff options
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/adt.rs | 9 | ||||
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 18 | ||||
-rw-r--r-- | crates/ra_hir/src/docs.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/generics.rs | 2 |
4 files changed, 19 insertions, 12 deletions
diff --git a/crates/ra_hir/src/adt.rs b/crates/ra_hir/src/adt.rs index 38ff1d6f6..36679e99b 100644 --- a/crates/ra_hir/src/adt.rs +++ b/crates/ra_hir/src/adt.rs | |||
@@ -59,8 +59,8 @@ impl StructData { | |||
59 | db: &(impl DefDatabase + AstDatabase), | 59 | db: &(impl DefDatabase + AstDatabase), |
60 | struct_: Struct, | 60 | struct_: Struct, |
61 | ) -> Arc<StructData> { | 61 | ) -> Arc<StructData> { |
62 | let (_, struct_def) = struct_.source(db); | 62 | let src = struct_.source(db); |
63 | Arc::new(StructData::new(&*struct_def)) | 63 | Arc::new(StructData::new(&*src.ast)) |
64 | } | 64 | } |
65 | } | 65 | } |
66 | 66 | ||
@@ -211,9 +211,8 @@ impl StructField { | |||
211 | let es; | 211 | let es; |
212 | let (file_id, struct_kind) = match self.parent { | 212 | let (file_id, struct_kind) = match self.parent { |
213 | VariantDef::Struct(s) => { | 213 | VariantDef::Struct(s) => { |
214 | let (file_id, source) = s.source(db); | 214 | ss = s.source(db); |
215 | ss = source; | 215 | (ss.file_id, ss.ast.kind()) |
216 | (file_id, ss.kind()) | ||
217 | } | 216 | } |
218 | VariantDef::EnumVariant(e) => { | 217 | VariantDef::EnumVariant(e) => { |
219 | let (file_id, source) = e.source(db); | 218 | let (file_id, source) = e.source(db); |
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 27850028b..3469da18a 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -20,6 +20,17 @@ use crate::{ | |||
20 | type_ref::Mutability, | 20 | type_ref::Mutability, |
21 | }; | 21 | }; |
22 | 22 | ||
23 | pub struct Source<T> { | ||
24 | pub file_id: HirFileId, | ||
25 | pub ast: T, | ||
26 | } | ||
27 | |||
28 | impl<T> From<(HirFileId, T)> for Source<T> { | ||
29 | fn from((file_id, ast): (HirFileId, T)) -> Self { | ||
30 | Source { file_id, ast } | ||
31 | } | ||
32 | } | ||
33 | |||
23 | /// hir::Crate describes a single crate. It's the main interface with which | 34 | /// hir::Crate describes a single crate. It's the main interface with which |
24 | /// a crate's dependencies interact. Mostly, it should be just a proxy for the | 35 | /// a crate's dependencies interact. Mostly, it should be just a proxy for the |
25 | /// root module. | 36 | /// root module. |
@@ -354,11 +365,8 @@ pub struct Struct { | |||
354 | } | 365 | } |
355 | 366 | ||
356 | impl Struct { | 367 | impl Struct { |
357 | pub fn source( | 368 | pub fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::StructDef>> { |
358 | self, | 369 | self.id.source(db).into() |
359 | db: &(impl DefDatabase + AstDatabase), | ||
360 | ) -> (HirFileId, TreeArc<ast::StructDef>) { | ||
361 | self.id.source(db) | ||
362 | } | 370 | } |
363 | 371 | ||
364 | pub fn module(self, db: &impl HirDatabase) -> Module { | 372 | pub fn module(self, db: &impl HirDatabase) -> Module { |
diff --git a/crates/ra_hir/src/docs.rs b/crates/ra_hir/src/docs.rs index 1b0f84de5..edd937901 100644 --- a/crates/ra_hir/src/docs.rs +++ b/crates/ra_hir/src/docs.rs | |||
@@ -76,7 +76,7 @@ pub(crate) fn documentation_query( | |||
76 | FieldSource::Named(named) => docs_from_ast(&*named), | 76 | FieldSource::Named(named) => docs_from_ast(&*named), |
77 | FieldSource::Pos(..) => return None, | 77 | FieldSource::Pos(..) => return None, |
78 | }, | 78 | }, |
79 | DocDef::Struct(it) => docs_from_ast(&*it.source(db).1), | 79 | DocDef::Struct(it) => docs_from_ast(&*it.source(db).ast), |
80 | DocDef::Enum(it) => docs_from_ast(&*it.source(db).1), | 80 | DocDef::Enum(it) => docs_from_ast(&*it.source(db).1), |
81 | DocDef::EnumVariant(it) => docs_from_ast(&*it.source(db).1), | 81 | DocDef::EnumVariant(it) => docs_from_ast(&*it.source(db).1), |
82 | DocDef::Static(it) => docs_from_ast(&*it.source(db).1), | 82 | DocDef::Static(it) => docs_from_ast(&*it.source(db).1), |
diff --git a/crates/ra_hir/src/generics.rs b/crates/ra_hir/src/generics.rs index b6c5e18d3..294a00721 100644 --- a/crates/ra_hir/src/generics.rs +++ b/crates/ra_hir/src/generics.rs | |||
@@ -69,7 +69,7 @@ impl GenericParams { | |||
69 | let start = generics.parent_params.as_ref().map(|p| p.params.len()).unwrap_or(0) as u32; | 69 | let start = generics.parent_params.as_ref().map(|p| p.params.len()).unwrap_or(0) as u32; |
70 | match def { | 70 | match def { |
71 | GenericDef::Function(it) => generics.fill(&*it.source(db).1, start), | 71 | GenericDef::Function(it) => generics.fill(&*it.source(db).1, start), |
72 | GenericDef::Struct(it) => generics.fill(&*it.source(db).1, start), | 72 | GenericDef::Struct(it) => generics.fill(&*it.source(db).ast, start), |
73 | GenericDef::Union(it) => generics.fill(&*it.source(db).1, start), | 73 | GenericDef::Union(it) => generics.fill(&*it.source(db).1, start), |
74 | GenericDef::Enum(it) => generics.fill(&*it.source(db).1, start), | 74 | GenericDef::Enum(it) => generics.fill(&*it.source(db).1, start), |
75 | GenericDef::Trait(it) => { | 75 | GenericDef::Trait(it) => { |