aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_expand
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_expand')
-rw-r--r--crates/ra_hir_expand/src/lib.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs
index c6ffa2c6f..930789b0f 100644
--- a/crates/ra_hir_expand/src/lib.rs
+++ b/crates/ra_hir_expand/src/lib.rs
@@ -223,7 +223,7 @@ impl<N: AstNode> AstId<N> {
223 } 223 }
224} 224}
225 225
226#[derive(Debug, PartialEq, Eq, Clone, Copy)] 226#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
227pub struct Source<T> { 227pub struct Source<T> {
228 pub file_id: HirFileId, 228 pub file_id: HirFileId,
229 pub ast: T, 229 pub ast: T,
@@ -233,6 +233,9 @@ impl<T> Source<T> {
233 pub fn map<F: FnOnce(T) -> U, U>(self, f: F) -> Source<U> { 233 pub fn map<F: FnOnce(T) -> U, U>(self, f: F) -> Source<U> {
234 Source { file_id: self.file_id, ast: f(self.ast) } 234 Source { file_id: self.file_id, ast: f(self.ast) }
235 } 235 }
236 pub fn as_ref(&self) -> Source<&T> {
237 Source { file_id: self.file_id, ast: &self.ast }
238 }
236 pub fn file_syntax(&self, db: &impl db::AstDatabase) -> SyntaxNode { 239 pub fn file_syntax(&self, db: &impl db::AstDatabase) -> SyntaxNode {
237 db.parse_or_expand(self.file_id).expect("source created from invalid file") 240 db.parse_or_expand(self.file_id).expect("source created from invalid file")
238 } 241 }