Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-core/src/diagnostic.rs')
| -rw-r--r-- | helix-core/src/diagnostic.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/helix-core/src/diagnostic.rs b/helix-core/src/diagnostic.rs index d41119d3..4e89361d 100644 --- a/helix-core/src/diagnostic.rs +++ b/helix-core/src/diagnostic.rs @@ -4,7 +4,8 @@ use std::fmt; use serde::{Deserialize, Serialize}; /// Describes the severity level of a [`Diagnostic`]. -#[derive(Debug, Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Deserialize, Serialize)] +#[derive(Debug, Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize)] +#[serde(rename_all = "lowercase")] pub enum Severity { Hint, Info, @@ -25,6 +26,12 @@ pub struct Range { pub end: usize, } +impl Range { + pub fn contains(self, pos: usize) -> bool { + (self.start..self.end).contains(&pos) + } +} + #[derive(Debug, Eq, Hash, PartialEq, Clone, Deserialize, Serialize)] pub enum NumberOrString { Number(i32), @@ -71,3 +78,10 @@ impl fmt::Display for LanguageServerId { write!(f, "{:?}", self.0) } } + +impl Diagnostic { + #[inline] + pub fn severity(&self) -> Severity { + self.severity.unwrap_or(Severity::Warning) + } +} |