diff options
author | Aleksey Kladov <[email protected]> | 2019-05-13 23:42:59 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-05-14 07:03:43 +0100 |
commit | 16c740526233b01980efdbb680b55718a71bb0e1 (patch) | |
tree | f68886b41ccc4134ad0dc038ed88005be50eee8d /crates/ra_hir/src/diagnostics.rs | |
parent | 101b3abfd70cc988b24f30a610d46a3986df54d3 (diff) |
expand to syntax node
Diffstat (limited to 'crates/ra_hir/src/diagnostics.rs')
-rw-r--r-- | crates/ra_hir/src/diagnostics.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/crates/ra_hir/src/diagnostics.rs b/crates/ra_hir/src/diagnostics.rs index d41525779..4b7b2dbee 100644 --- a/crates/ra_hir/src/diagnostics.rs +++ b/crates/ra_hir/src/diagnostics.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use std::{fmt, any::Any}; | 1 | use std::{fmt, any::Any}; |
2 | 2 | ||
3 | use ra_syntax::{SyntaxNodePtr, TreeArc, AstPtr, TextRange, ast, SyntaxNode, AstNode}; | 3 | use ra_syntax::{SyntaxNodePtr, TreeArc, AstPtr, TextRange, ast, SyntaxNode}; |
4 | use relative_path::RelativePathBuf; | 4 | use relative_path::RelativePathBuf; |
5 | 5 | ||
6 | use crate::{HirFileId, HirDatabase, Name}; | 6 | use crate::{HirFileId, HirDatabase, Name}; |
@@ -29,8 +29,8 @@ pub trait Diagnostic: Any + Send + Sync + fmt::Debug + 'static { | |||
29 | 29 | ||
30 | impl dyn Diagnostic { | 30 | impl dyn Diagnostic { |
31 | pub fn syntax_node(&self, db: &impl HirDatabase) -> TreeArc<SyntaxNode> { | 31 | pub fn syntax_node(&self, db: &impl HirDatabase) -> TreeArc<SyntaxNode> { |
32 | let source_file = db.hir_parse(self.file()); | 32 | let node = db.parse_or_expand(self.file()).unwrap(); |
33 | self.syntax_node_ptr().to_node(source_file.syntax()).to_owned() | 33 | self.syntax_node_ptr().to_node(&*node).to_owned() |
34 | } | 34 | } |
35 | pub fn downcast_ref<D: Diagnostic>(&self) -> Option<&D> { | 35 | pub fn downcast_ref<D: Diagnostic>(&self) -> Option<&D> { |
36 | self.as_any().downcast_ref() | 36 | self.as_any().downcast_ref() |