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.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/crates/ra_hir_expand/src/diagnostics.rs b/crates/ra_hir_expand/src/diagnostics.rs
index 23f28a7f7..90a3b87f9 100644
--- a/crates/ra_hir_expand/src/diagnostics.rs
+++ b/crates/ra_hir_expand/src/diagnostics.rs
@@ -22,9 +22,11 @@ use crate::{db::AstDatabase, InFile};
22 22
23pub trait Diagnostic: Any + Send + Sync + fmt::Debug + 'static { 23pub trait Diagnostic: Any + Send + Sync + fmt::Debug + 'static {
24 fn message(&self) -> String; 24 fn message(&self) -> String;
25 fn fix_source(&self) -> InFile<SyntaxNodePtr>; 25 /// A source to be used in highlighting and other visual representations
26 fn source(&self) -> InFile<SyntaxNodePtr> { 26 fn source(&self) -> InFile<SyntaxNodePtr>;
27 self.fix_source() 27 /// A source to be used during the fix application
28 fn fix_source(&self) -> InFile<SyntaxNodePtr> {
29 self.source()
28 } 30 }
29 fn as_any(&self) -> &(dyn Any + Send + 'static); 31 fn as_any(&self) -> &(dyn Any + Send + 'static);
30 fn is_experimental(&self) -> bool { 32 fn is_experimental(&self) -> bool {
@@ -39,8 +41,9 @@ pub trait AstDiagnostic {
39 41
40impl dyn Diagnostic { 42impl dyn Diagnostic {
41 pub fn syntax_node(&self, db: &impl AstDatabase) -> SyntaxNode { 43 pub fn syntax_node(&self, db: &impl AstDatabase) -> SyntaxNode {
42 let node = db.parse_or_expand(self.source().file_id).unwrap(); 44 let source = self.source();
43 self.source().value.to_node(&node) 45 let node = db.parse_or_expand(source.file_id).unwrap();
46 source.value.to_node(&node)
44 } 47 }
45 48
46 pub fn downcast_ref<D: Diagnostic>(&self) -> Option<&D> { 49 pub fn downcast_ref<D: Diagnostic>(&self) -> Option<&D> {