aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/code_model.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-06-11 00:34:34 +0100
committerAleksey Kladov <[email protected]>2019-06-11 16:28:51 +0100
commit91c120ccea4f0cfef20fd4d918154c8152f83816 (patch)
treef175e9308486f8594618236d63737042f546b37a /crates/ra_hir/src/code_model.rs
parente505fe9d7b96f3454711e923c70d763c5cee5f47 (diff)
introduce Source struct
Diffstat (limited to 'crates/ra_hir/src/code_model.rs')
-rw-r--r--crates/ra_hir/src/code_model.rs18
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
23pub struct Source<T> {
24 pub file_id: HirFileId,
25 pub ast: T,
26}
27
28impl<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
356impl Struct { 367impl 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 {