From 91c120ccea4f0cfef20fd4d918154c8152f83816 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 11 Jun 2019 02:34:34 +0300 Subject: introduce Source struct --- crates/ra_hir/src/code_model.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'crates/ra_hir/src/code_model.rs') 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::{ type_ref::Mutability, }; +pub struct Source { + pub file_id: HirFileId, + pub ast: T, +} + +impl From<(HirFileId, T)> for Source { + fn from((file_id, ast): (HirFileId, T)) -> Self { + Source { file_id, ast } + } +} + /// hir::Crate describes a single crate. It's the main interface with which /// a crate's dependencies interact. Mostly, it should be just a proxy for the /// root module. @@ -354,11 +365,8 @@ pub struct Struct { } impl Struct { - pub fn source( - self, - db: &(impl DefDatabase + AstDatabase), - ) -> (HirFileId, TreeArc) { - self.id.source(db) + pub fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source> { + self.id.source(db).into() } pub fn module(self, db: &impl HirDatabase) -> Module { -- cgit v1.2.3