aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-11-28 15:14:08 +0000
committerAleksey Kladov <[email protected]>2020-11-28 15:14:08 +0000
commit5a42e6bff541d42d6366a93b619b20732bb48dcf (patch)
tree1e0f7c141acdf5a330eac5e8db361fd3a3996eca
parentb7ece77af49ce59762fc3246a4c721411efe637e (diff)
Explain how we get precise spans for diagnostics.
-rw-r--r--crates/hir_expand/src/diagnostics.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/crates/hir_expand/src/diagnostics.rs b/crates/hir_expand/src/diagnostics.rs
index 1043c6aeb..bf0b85ce9 100644
--- a/crates/hir_expand/src/diagnostics.rs
+++ b/crates/hir_expand/src/diagnostics.rs
@@ -5,7 +5,7 @@
5//! 5//!
6//! `DiagnosticSink` struct is used as an emitter for diagnostic. When creating 6//! `DiagnosticSink` struct is used as an emitter for diagnostic. When creating
7//! a `DiagnosticSink`, you supply a callback which can react to a `dyn 7//! a `DiagnosticSink`, you supply a callback which can react to a `dyn
8//! Diagnostic` or to any concrete diagnostic (downcasting is sued internally). 8//! Diagnostic` or to any concrete diagnostic (downcasting is used internally).
9//! 9//!
10//! Because diagnostics store file offsets, it's a bad idea to store them 10//! Because diagnostics store file offsets, it's a bad idea to store them
11//! directly in salsa. For this reason, every hir subsytem defines it's own 11//! directly in salsa. For this reason, every hir subsytem defines it's own
@@ -32,7 +32,12 @@ impl DiagnosticCode {
32pub trait Diagnostic: Any + Send + Sync + fmt::Debug + 'static { 32pub trait Diagnostic: Any + Send + Sync + fmt::Debug + 'static {
33 fn code(&self) -> DiagnosticCode; 33 fn code(&self) -> DiagnosticCode;
34 fn message(&self) -> String; 34 fn message(&self) -> String;
35 /// Used in highlighting and related purposes 35 /// Source element that triggered the diagnostics.
36 ///
37 /// Note that this should reflect "semantics", rather than specific span we
38 /// want to highlight. When rendering the diagnostics into an error message,
39 /// the IDE will fetch the `SyntaxNode` and will narrow the span
40 /// appropriately.
36 fn display_source(&self) -> InFile<SyntaxNodePtr>; 41 fn display_source(&self) -> InFile<SyntaxNodePtr>;
37 fn as_any(&self) -> &(dyn Any + Send + 'static); 42 fn as_any(&self) -> &(dyn Any + Send + 'static);
38 fn is_experimental(&self) -> bool { 43 fn is_experimental(&self) -> bool {