diff options
author | Kirill Bulatov <[email protected]> | 2020-07-27 20:30:55 +0100 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2020-08-11 13:09:08 +0100 |
commit | a61f2445cba2a48bb7ea6c8477e3198b297f3c67 (patch) | |
tree | cce28de2e55620a94041fb481e914b16da5569d9 /crates/ra_hir_expand/src | |
parent | 21e5224484b9214648826e1b15aa9150c79a407c (diff) |
Less stubs
Diffstat (limited to 'crates/ra_hir_expand/src')
-rw-r--r-- | crates/ra_hir_expand/src/diagnostics.rs | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/crates/ra_hir_expand/src/diagnostics.rs b/crates/ra_hir_expand/src/diagnostics.rs index e889f070f..ffeca5e82 100644 --- a/crates/ra_hir_expand/src/diagnostics.rs +++ b/crates/ra_hir_expand/src/diagnostics.rs | |||
@@ -16,13 +16,16 @@ | |||
16 | 16 | ||
17 | use std::{any::Any, fmt}; | 17 | use std::{any::Any, fmt}; |
18 | 18 | ||
19 | use ra_syntax::{SyntaxNode, SyntaxNodePtr}; | 19 | use ra_syntax::SyntaxNodePtr; |
20 | 20 | ||
21 | use crate::{db::AstDatabase, InFile}; | 21 | use crate::{db::AstDatabase, InFile}; |
22 | 22 | ||
23 | pub trait Diagnostic: Any + Send + Sync + fmt::Debug + 'static { | 23 | pub trait Diagnostic: Any + Send + Sync + fmt::Debug + 'static { |
24 | fn message(&self) -> String; | 24 | fn message(&self) -> String; |
25 | fn source(&self) -> InFile<SyntaxNodePtr>; | 25 | fn source(&self) -> InFile<SyntaxNodePtr>; |
26 | fn highlighting_source(&self) -> InFile<SyntaxNodePtr> { | ||
27 | self.source() | ||
28 | } | ||
26 | fn as_any(&self) -> &(dyn Any + Send + 'static); | 29 | fn as_any(&self) -> &(dyn Any + Send + 'static); |
27 | fn is_experimental(&self) -> bool { | 30 | fn is_experimental(&self) -> bool { |
28 | false | 31 | false |
@@ -35,12 +38,6 @@ pub trait AstDiagnostic { | |||
35 | } | 38 | } |
36 | 39 | ||
37 | impl dyn Diagnostic { | 40 | impl dyn Diagnostic { |
38 | pub fn syntax_node(&self, db: &impl AstDatabase) -> SyntaxNode { | ||
39 | let source = self.source(); | ||
40 | let node = db.parse_or_expand(source.file_id).unwrap(); | ||
41 | source.value.to_node(&node) | ||
42 | } | ||
43 | |||
44 | pub fn downcast_ref<D: Diagnostic>(&self) -> Option<&D> { | 41 | pub fn downcast_ref<D: Diagnostic>(&self) -> Option<&D> { |
45 | self.as_any().downcast_ref() | 42 | self.as_any().downcast_ref() |
46 | } | 43 | } |