Struct Diagnostic
pub struct Diagnostic {
pub range: Range<usize>,
pub severity: DiagnosticSeverity,
pub message: String,
pub source: DiagnosticSource,
pub document_version: Option<DocumentVersion>,
}Expand description
Diagnostic attached to a byte range in a code document.
Ranges are UTF-8 byte offsets and are not normalized or clamped here. Empty and reversed ranges are representable; hit testing uses inclusive endpoints.
§Examples
use ailloli_ui_editor::{Diagnostic, DiagnosticSeverity, DiagnosticSource};
let diagnostic = Diagnostic::new(2..5, DiagnosticSeverity::Warning, "unused");
assert_eq!(diagnostic.source, DiagnosticSource::Local);
assert_eq!(diagnostic.range, 2..5);Fields§
§range: Range<usize>Unvalidated UTF-8 byte range.
severity: DiagnosticSeverityError, warning, information, or hint level.
message: StringExact owned human-readable message; empty is allowed.
source: DiagnosticSourceLocal or language-server provenance.
document_version: Option<DocumentVersion>Source document revision for LSP diagnostics, otherwise None by default.
Implementations§
§impl Diagnostic
Diagnostic constructors.
impl Diagnostic
Diagnostic constructors.
pub fn new(
range: Range<usize>,
severity: DiagnosticSeverity,
message: impl Into<String>,
) -> Diagnostic
pub fn new( range: Range<usize>, severity: DiagnosticSeverity, message: impl Into<String>, ) -> Diagnostic
Creates a local diagnostic with no document version.
§Examples
use ailloli_ui_editor::{Diagnostic, DiagnosticSeverity, DiagnosticSource};
let diagnostic = Diagnostic::new(0..0, DiagnosticSeverity::Hint, "");
assert_eq!(diagnostic.source, DiagnosticSource::Local);
assert_eq!(diagnostic.document_version, None);pub fn lsp(
range: Range<usize>,
severity: DiagnosticSeverity,
message: impl Into<String>,
document_version: DocumentVersion,
) -> Diagnostic
pub fn lsp( range: Range<usize>, severity: DiagnosticSeverity, message: impl Into<String>, document_version: DocumentVersion, ) -> Diagnostic
Creates an LSP diagnostic tied to an exact document version.
§Examples
use ailloli_ui_editor::{Diagnostic, DiagnosticSeverity, DiagnosticSource, DocumentVersion};
let diagnostic = Diagnostic::lsp(1..3, DiagnosticSeverity::Error, "bad", DocumentVersion(4));
assert_eq!(diagnostic.source, DiagnosticSource::Lsp);
assert_eq!(diagnostic.document_version, Some(DocumentVersion(4)));Trait Implementations§
§impl Clone for Diagnostic
impl Clone for Diagnostic
§fn clone(&self) -> Diagnostic
fn clone(&self) -> Diagnostic
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more§impl Debug for Diagnostic
impl Debug for Diagnostic
§impl<'de> Deserialize<'de> for Diagnostic
impl<'de> Deserialize<'de> for Diagnostic
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Diagnostic, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Diagnostic, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
§impl PartialEq for Diagnostic
impl PartialEq for Diagnostic
§impl Serialize for Diagnostic
impl Serialize for Diagnostic
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Eq for Diagnostic
impl StructuralPartialEq for Diagnostic
Auto Trait Implementations§
impl Freeze for Diagnostic
impl RefUnwindSafe for Diagnostic
impl Send for Diagnostic
impl Sync for Diagnostic
impl Unpin 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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
§fn into_click_action(self) -> ClickAction<A>
fn into_click_action(self) -> ClickAction<A>
Implements the into_click_action helper used by this module.