mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 05:45:12 +00:00
expand to syntax node
This commit is contained in:
parent
101b3abfd7
commit
16c7405262
6 changed files with 33 additions and 26 deletions
|
@ -1,6 +1,6 @@
|
|||
use std::{fmt, any::Any};
|
||||
|
||||
use ra_syntax::{SyntaxNodePtr, TreeArc, AstPtr, TextRange, ast, SyntaxNode, AstNode};
|
||||
use ra_syntax::{SyntaxNodePtr, TreeArc, AstPtr, TextRange, ast, SyntaxNode};
|
||||
use relative_path::RelativePathBuf;
|
||||
|
||||
use crate::{HirFileId, HirDatabase, Name};
|
||||
|
@ -29,8 +29,8 @@ pub trait Diagnostic: Any + Send + Sync + fmt::Debug + 'static {
|
|||
|
||||
impl dyn Diagnostic {
|
||||
pub fn syntax_node(&self, db: &impl HirDatabase) -> TreeArc<SyntaxNode> {
|
||||
let source_file = db.hir_parse(self.file());
|
||||
self.syntax_node_ptr().to_node(source_file.syntax()).to_owned()
|
||||
let node = db.parse_or_expand(self.file()).unwrap();
|
||||
self.syntax_node_ptr().to_node(&*node).to_owned()
|
||||
}
|
||||
pub fn downcast_ref<D: Diagnostic>(&self) -> Option<&D> {
|
||||
self.as_any().downcast_ref()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue