1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use super::Range;
use jsonrpc::Value;

/// A document link is a range in a text document that links to an internal or external resource, like another
/// text document or a web site.
#[derive(Debug, Serialize)]
pub struct DocumentLink {
    /// The range this link applies to.
    pub range: Range,

    /// The uri this link points to.
    pub target: Option<String>,

    /// A data entry field that is preserved on a document link between a
    /// DocumentLinkRequest and a DocumentLinkResolveRequest.
    pub data: Option<Value>,
}

/// The DocumentLink namespace provides helper functions to work with
/// [DocumentLink](#DocumentLink) literals.
impl DocumentLink {
    /// Creates a new DocumentLink literal.
    pub fn create(range: Range, target: Option<String>, data: Option<Value>) -> Self {
        DocumentLink {
            range,
            target,
            data,
        }
    }
}