aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_expand/src
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2020-07-27 20:30:55 +0100
committerKirill Bulatov <[email protected]>2020-08-11 13:09:08 +0100
commita61f2445cba2a48bb7ea6c8477e3198b297f3c67 (patch)
treecce28de2e55620a94041fb481e914b16da5569d9 /crates/ra_hir_expand/src
parent21e5224484b9214648826e1b15aa9150c79a407c (diff)
Less stubs
Diffstat (limited to 'crates/ra_hir_expand/src')
-rw-r--r--crates/ra_hir_expand/src/diagnostics.rs11
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
17use std::{any::Any, fmt}; 17use std::{any::Any, fmt};
18 18
19use ra_syntax::{SyntaxNode, SyntaxNodePtr}; 19use ra_syntax::SyntaxNodePtr;
20 20
21use crate::{db::AstDatabase, InFile}; 21use 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 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
37impl dyn Diagnostic { 40impl 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 }