diff options
Diffstat (limited to 'crates/ra_hir/src/code_model.rs')
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 18 |
1 files changed, 13 insertions, 5 deletions
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 { |