From 302bf97bbf1855e3c7def9ab4f9f3d338be5e3b7 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 17 Apr 2020 11:38:51 +0200 Subject: Don't expose impl details of SyntaxPtr --- crates/ra_hir_def/src/diagnostics.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'crates/ra_hir_def/src/diagnostics.rs') diff --git a/crates/ra_hir_def/src/diagnostics.rs b/crates/ra_hir_def/src/diagnostics.rs index cfa0f2f76..dbaf4deef 100644 --- a/crates/ra_hir_def/src/diagnostics.rs +++ b/crates/ra_hir_def/src/diagnostics.rs @@ -4,7 +4,7 @@ use std::any::Any; use hir_expand::diagnostics::Diagnostic; use ra_db::RelativePathBuf; -use ra_syntax::{ast, AstPtr, SyntaxNodePtr}; +use ra_syntax::{ast, AstPtr, SyntaxNodePtr, TextRange}; use hir_expand::{HirFileId, InFile}; @@ -12,6 +12,7 @@ use hir_expand::{HirFileId, InFile}; pub struct UnresolvedModule { pub file: HirFileId, pub decl: AstPtr, + pub highlight_range: TextRange, pub candidate: RelativePathBuf, } @@ -19,6 +20,9 @@ impl Diagnostic for UnresolvedModule { fn message(&self) -> String { "unresolved module".to_string() } + fn highlight_range(&self) -> TextRange { + self.highlight_range + } fn source(&self) -> InFile { InFile { file_id: self.file, value: self.decl.clone().into() } } -- cgit v1.2.3 From a8196ffe8466aa60dec56e77c2da717793c0debe Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 17 Apr 2020 13:06:02 +0200 Subject: Correctly highlight ranges of diagnostics from macros closes #2799 --- crates/ra_hir_def/src/diagnostics.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'crates/ra_hir_def/src/diagnostics.rs') diff --git a/crates/ra_hir_def/src/diagnostics.rs b/crates/ra_hir_def/src/diagnostics.rs index dbaf4deef..2ee28fbaa 100644 --- a/crates/ra_hir_def/src/diagnostics.rs +++ b/crates/ra_hir_def/src/diagnostics.rs @@ -20,11 +20,11 @@ impl Diagnostic for UnresolvedModule { fn message(&self) -> String { "unresolved module".to_string() } - fn highlight_range(&self) -> TextRange { - self.highlight_range + fn highlight_range(&self) -> InFile { + InFile::new(self.file, self.highlight_range) } fn source(&self) -> InFile { - InFile { file_id: self.file, value: self.decl.clone().into() } + InFile::new(self.file, self.decl.clone().into()) } fn as_any(&self) -> &(dyn Any + Send + 'static) { self -- cgit v1.2.3 From 146f6f5a45a4bfd98ab0eb54bb30610d784433c9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 17 Apr 2020 13:55:05 +0200 Subject: Simplify Diagnostic structure It's not entirely clear what subnode ranges should mean in the presence of macros, so let's leave them out for now. We are not using them heavily anyway. --- crates/ra_hir_def/src/diagnostics.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'crates/ra_hir_def/src/diagnostics.rs') diff --git a/crates/ra_hir_def/src/diagnostics.rs b/crates/ra_hir_def/src/diagnostics.rs index 2ee28fbaa..510c5e064 100644 --- a/crates/ra_hir_def/src/diagnostics.rs +++ b/crates/ra_hir_def/src/diagnostics.rs @@ -4,7 +4,7 @@ use std::any::Any; use hir_expand::diagnostics::Diagnostic; use ra_db::RelativePathBuf; -use ra_syntax::{ast, AstPtr, SyntaxNodePtr, TextRange}; +use ra_syntax::{ast, AstPtr, SyntaxNodePtr}; use hir_expand::{HirFileId, InFile}; @@ -12,7 +12,6 @@ use hir_expand::{HirFileId, InFile}; pub struct UnresolvedModule { pub file: HirFileId, pub decl: AstPtr, - pub highlight_range: TextRange, pub candidate: RelativePathBuf, } @@ -20,9 +19,6 @@ impl Diagnostic for UnresolvedModule { fn message(&self) -> String { "unresolved module".to_string() } - fn highlight_range(&self) -> InFile { - InFile::new(self.file, self.highlight_range) - } fn source(&self) -> InFile { InFile::new(self.file, self.decl.clone().into()) } -- cgit v1.2.3