From 9963f43d51071ea02f8f6d490b9c49882034b42c Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sun, 9 Aug 2020 01:59:26 +0300 Subject: Refactor the diagnostics --- crates/ra_hir_expand/src/diagnostics.rs | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'crates/ra_hir_expand/src') diff --git a/crates/ra_hir_expand/src/diagnostics.rs b/crates/ra_hir_expand/src/diagnostics.rs index 90a3b87f9..2b74473ce 100644 --- a/crates/ra_hir_expand/src/diagnostics.rs +++ b/crates/ra_hir_expand/src/diagnostics.rs @@ -16,18 +16,13 @@ use std::{any::Any, fmt}; -use ra_syntax::{SyntaxNode, SyntaxNodePtr}; +use ra_syntax::SyntaxNodePtr; use crate::{db::AstDatabase, InFile}; pub trait Diagnostic: Any + Send + Sync + fmt::Debug + 'static { fn message(&self) -> String; - /// A source to be used in highlighting and other visual representations - fn source(&self) -> InFile; - /// A source to be used during the fix application - fn fix_source(&self) -> InFile { - self.source() - } + fn presentation(&self) -> InFile; fn as_any(&self) -> &(dyn Any + Send + 'static); fn is_experimental(&self) -> bool { false @@ -36,16 +31,10 @@ pub trait Diagnostic: Any + Send + Sync + fmt::Debug + 'static { pub trait AstDiagnostic { type AST; - fn ast(&self, db: &dyn AstDatabase) -> Self::AST; + fn fix_source(&self, db: &dyn AstDatabase) -> Self::AST; } impl dyn Diagnostic { - pub fn syntax_node(&self, db: &impl AstDatabase) -> SyntaxNode { - let source = self.source(); - let node = db.parse_or_expand(source.file_id).unwrap(); - source.value.to_node(&node) - } - pub fn downcast_ref(&self) -> Option<&D> { self.as_any().downcast_ref() } -- cgit v1.2.3