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/diagnostics.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/crates/ra_hir_expand/src/diagnostics.rs b/crates/ra_hir_expand/src/diagnostics.rs
index 074a8c45e..23f28a7f7 100644
--- a/crates/ra_hir_expand/src/diagnostics.rs
+++ b/crates/ra_hir_expand/src/diagnostics.rs
@@ -16,7 +16,7 @@
16 16
17use std::{any::Any, fmt}; 17use std::{any::Any, fmt};
18 18
19use ra_syntax::SyntaxNodePtr; 19use ra_syntax::{SyntaxNode, SyntaxNodePtr};
20 20
21use crate::{db::AstDatabase, InFile}; 21use crate::{db::AstDatabase, InFile};
22 22
@@ -38,6 +38,11 @@ pub trait AstDiagnostic {
38} 38}
39 39
40impl dyn Diagnostic { 40impl dyn Diagnostic {
41 pub fn syntax_node(&self, db: &impl AstDatabase) -> SyntaxNode {
42 let node = db.parse_or_expand(self.source().file_id).unwrap();
43 self.source().value.to_node(&node)
44 }
45
41 pub fn downcast_ref<D: Diagnostic>(&self) -> Option<&D> { 46 pub fn downcast_ref<D: Diagnostic>(&self) -> Option<&D> {
42 self.as_any().downcast_ref() 47 self.as_any().downcast_ref()
43 } 48 }