pub struct Diagnostic {
pub range: LspRange,
pub severity: DiagnosticSeverity,
pub message: String,
pub source: Option<String>,
}Expand description
LSP integration types and traits for editor clients. LSP integration types and traits for editor clients. LSP integration types and traits for editor clients. A diagnostic range to underline in the editor.
Passed to CodeEditor::set_diagnostics. The range uses logical lines and
character columns (not UTF-16 offsets). The message is what a host shows
when the pointer hovers the range (see CodeEditor::diagnostics_at).
§Example
use iced_code_editor::{Diagnostic, DiagnosticSeverity, LspPosition, LspRange};
let diagnostic = Diagnostic::new(
LspRange {
start: LspPosition { line: 2, character: 0 },
end: LspPosition { line: 2, character: 5 },
},
DiagnosticSeverity::Error,
"mismatched types",
);
assert_eq!(diagnostic.range.end.character, 5);
assert_eq!(diagnostic.message, "mismatched types");Fields§
§range: LspRangeRange to underline, with an inclusive start and exclusive end.
severity: DiagnosticSeveritySeverity that determines the underline color.
message: StringHuman-readable description of the problem. May be empty.
source: Option<String>Tool that produced the diagnostic, such as rustc or clippy.
None when the source did not say.
Implementations§
Source§impl Diagnostic
impl Diagnostic
Sourcepub fn new(
range: LspRange,
severity: DiagnosticSeverity,
message: impl Into<String>,
) -> Self
pub fn new( range: LspRange, severity: DiagnosticSeverity, message: impl Into<String>, ) -> Self
Creates a diagnostic from its range, severity and message.
§Example
use iced_code_editor::{Diagnostic, DiagnosticSeverity, LspPosition, LspRange};
let at = LspPosition { line: 0, character: 3 };
let diagnostic = Diagnostic::new(
LspRange { start: at, end: at },
DiagnosticSeverity::Hint,
"consider a shorter name",
);
assert_eq!(diagnostic.severity, DiagnosticSeverity::Hint);Sourcepub fn with_source(self, source: impl Into<String>) -> Self
pub fn with_source(self, source: impl Into<String>) -> Self
Sets the tool that produced the diagnostic, such as rustc or
clippy.
§Example
use iced_code_editor::{Diagnostic, DiagnosticSeverity, LspPosition, LspRange};
let at = LspPosition { line: 0, character: 0 };
let diagnostic = Diagnostic::new(
LspRange { start: at, end: at },
DiagnosticSeverity::Warning,
"redundant clone",
)
.with_source("clippy");
assert_eq!(diagnostic.source.as_deref(), Some("clippy"));Sourcepub fn contains(&self, position: LspPosition) -> bool
pub fn contains(&self, position: LspPosition) -> bool
Whether position lies on the characters this diagnostic underlines.
The end is exclusive. An empty range covers the one character at its start, which is the character the editor underlines for it. A reversed range covers nothing.
§Example
use iced_code_editor::{Diagnostic, DiagnosticSeverity, LspPosition, LspRange};
let diagnostic = Diagnostic::new(
LspRange {
start: LspPosition { line: 0, character: 4 },
end: LspPosition { line: 0, character: 8 },
},
DiagnosticSeverity::Error,
"unknown name",
);
assert!(diagnostic.contains(LspPosition { line: 0, character: 4 }));
assert!(!diagnostic.contains(LspPosition { line: 0, character: 8 }));Trait Implementations§
Source§impl Clone for Diagnostic
impl Clone for Diagnostic
Source§impl Debug for Diagnostic
impl Debug for Diagnostic
impl Eq for Diagnostic
Source§impl PartialEq for Diagnostic
impl PartialEq for Diagnostic
impl StructuralPartialEq for Diagnostic
Auto Trait Implementations§
impl Forget for Diagnostic
impl Freeze for Diagnostic
impl Move for Diagnostic
impl RefUnwindSafe for Diagnostic
impl Send for Diagnostic
impl Sync for Diagnostic
impl Unpin for Diagnostic
impl UnsafeUnpin for Diagnostic
impl UnwindSafe for Diagnostic
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<State, Message> IntoBoot<State, Message> for State
impl<State, Message> IntoBoot<State, Message> for State
Source§fn into_boot(self) -> (State, Task<Message>)
fn into_boot(self) -> (State, Task<Message>)
Application.