2021-10-25 18:02:16 +02:00
|
|
|
//! LSP diagnostic utility types.
|
2021-12-25 06:32:43 +01:00
|
|
|
use serde::{Deserialize, Serialize};
|
2021-10-25 18:02:16 +02:00
|
|
|
|
|
|
|
/// Describes the severity level of a [`Diagnostic`].
|
2021-12-25 06:32:43 +01:00
|
|
|
#[derive(Debug, Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Deserialize, Serialize)]
|
2021-03-11 08:31:49 +01:00
|
|
|
pub enum Severity {
|
|
|
|
Hint,
|
2021-12-25 06:32:43 +01:00
|
|
|
Info,
|
|
|
|
Warning,
|
|
|
|
Error,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for Severity {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self::Hint
|
|
|
|
}
|
2021-03-11 08:31:49 +01:00
|
|
|
}
|
|
|
|
|
2021-10-25 18:02:16 +02:00
|
|
|
/// A range of `char`s within the text.
|
2021-11-06 10:58:40 +01:00
|
|
|
#[derive(Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq)]
|
2021-03-15 08:19:31 +01:00
|
|
|
pub struct Range {
|
|
|
|
pub start: usize,
|
|
|
|
pub end: usize,
|
|
|
|
}
|
2021-06-06 17:55:05 +02:00
|
|
|
|
2021-10-25 18:02:16 +02:00
|
|
|
/// Corresponds to [`lsp_types::Diagnostic`](https://docs.rs/lsp-types/0.91.0/lsp_types/struct.Diagnostic.html)
|
2021-09-24 03:29:41 +02:00
|
|
|
#[derive(Debug, Clone)]
|
2020-10-20 08:42:53 +02:00
|
|
|
pub struct Diagnostic {
|
2021-03-15 08:19:31 +01:00
|
|
|
pub range: Range,
|
2020-10-20 08:42:53 +02:00
|
|
|
pub line: usize,
|
|
|
|
pub message: String,
|
2021-03-11 08:31:49 +01:00
|
|
|
pub severity: Option<Severity>,
|
2020-10-20 08:42:53 +02:00
|
|
|
}
|