diff options
author | Kirill Bulatov <[email protected]> | 2020-08-08 23:59:26 +0100 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2020-08-11 13:09:08 +0100 |
commit | 9963f43d51071ea02f8f6d490b9c49882034b42c (patch) | |
tree | 7ecdbbd66fb8c988989e6de17c77ab14262589c0 /crates/ra_hir_def | |
parent | cfbbd91a886e2394e7411f9d7f4966dcbd454764 (diff) |
Refactor the diagnostics
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r-- | crates/ra_hir_def/src/diagnostics.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/crates/ra_hir_def/src/diagnostics.rs b/crates/ra_hir_def/src/diagnostics.rs index 30db48f86..be9612846 100644 --- a/crates/ra_hir_def/src/diagnostics.rs +++ b/crates/ra_hir_def/src/diagnostics.rs | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | use std::any::Any; | 3 | use std::any::Any; |
4 | 4 | ||
5 | use hir_expand::diagnostics::Diagnostic; | 5 | use hir_expand::diagnostics::{AstDiagnostic, Diagnostic}; |
6 | use ra_syntax::{ast, AstPtr, SyntaxNodePtr}; | 6 | use ra_syntax::{ast, AstPtr, SyntaxNodePtr}; |
7 | 7 | ||
8 | use hir_expand::{HirFileId, InFile}; | 8 | use hir_expand::{HirFileId, InFile}; |
@@ -18,10 +18,18 @@ impl Diagnostic for UnresolvedModule { | |||
18 | fn message(&self) -> String { | 18 | fn message(&self) -> String { |
19 | "unresolved module".to_string() | 19 | "unresolved module".to_string() |
20 | } | 20 | } |
21 | fn source(&self) -> InFile<SyntaxNodePtr> { | 21 | fn presentation(&self) -> InFile<SyntaxNodePtr> { |
22 | InFile::new(self.file, self.decl.clone().into()) | 22 | InFile::new(self.file, self.decl.clone().into()) |
23 | } | 23 | } |
24 | fn as_any(&self) -> &(dyn Any + Send + 'static) { | 24 | fn as_any(&self) -> &(dyn Any + Send + 'static) { |
25 | self | 25 | self |
26 | } | 26 | } |
27 | } | 27 | } |
28 | |||
29 | impl AstDiagnostic for UnresolvedModule { | ||
30 | type AST = ast::Module; | ||
31 | fn fix_source(&self, db: &dyn hir_expand::db::AstDatabase) -> Self::AST { | ||
32 | let root = db.parse_or_expand(self.file).unwrap(); | ||
33 | self.decl.to_node(&root) | ||
34 | } | ||
35 | } | ||