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§
Source§impl Diagnostic
Diagnostic constructors.
impl Diagnostic
Diagnostic constructors.
Sourcepub fn new(
range: Range<usize>,
severity: DiagnosticSeverity,
message: impl Into<String>,
) -> Self
pub fn new( range: Range<usize>, severity: DiagnosticSeverity, message: impl Into<String>, ) -> Self
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);Sourcepub fn lsp(
range: Range<usize>,
severity: DiagnosticSeverity,
message: impl Into<String>,
document_version: DocumentVersion,
) -> Self
pub fn lsp( range: Range<usize>, severity: DiagnosticSeverity, message: impl Into<String>, document_version: DocumentVersion, ) -> Self
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§
Source§impl Clone for Diagnostic
impl Clone for Diagnostic
Source§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 moreSource§impl Debug for Diagnostic
impl Debug for Diagnostic
Source§impl<'de> Deserialize<'de> for Diagnostic
impl<'de> Deserialize<'de> for Diagnostic
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for Diagnostic
impl PartialEq for Diagnostic
Source§impl Serialize for Diagnostic
impl Serialize for Diagnostic
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.