1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use super::{DocumentHighlightKind, Range};

/// A document highlight is a range inside a text document which deserves
/// special attention. Usually a document highlight is visualized by changing
/// the background color of its range.
#[derive(Debug, Serialize)]
pub struct DocumentHighlight {
    /// The range this highlight applies to.
    pub range: Range,

    /// The highlight kind, default is [text](#DocumentHighlightKind.Text).
    pub kind: Option<DocumentHighlightKind>,
}

/// DocumentHighlight namespace to provide helper functions to work with
/// [DocumentHighlight](#DocumentHighlight) literals.
impl DocumentHighlight {
    /// Create a DocumentHighlight object.
    /// @param range The range the highlight applies to.
    pub fn create(range: Range, kind: Option<DocumentHighlightKind>) -> Self {
        DocumentHighlight { range, kind }
    }
}