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
31
32
33
34
35
use lsp_types::TextDocumentIdentifier;
use serde::{Deserialize, Serialize};

use super::BuildTargetIdentifier;

/// The inverse sources request is sent from the client to the server to query for the list of
/// build targets containing a text document. The server communicates during the initialize
/// handshake whether this method is supported or not. This request can be viewed as the inverse of
/// buildTarget/sources, except it only works for text documents and not directories.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct TextDocumentInverseSources {
    text_document: TextDocumentIdentifier,
}

impl TextDocumentInverseSources {
    pub fn new(text_document: TextDocumentIdentifier) -> Self {
        Self { text_document }
    }

    /// Get a reference to the bsp inverse sources params's text document.
    pub fn text_document(&self) -> &TextDocumentIdentifier {
        &self.text_document
    }

    /// Set the bsp inverse sources params's text document.
    pub fn set_text_document(&mut self, text_document: TextDocumentIdentifier) {
        self.text_document = text_document;
    }
}

#[derive(Default, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct BuildTargetInverseSourcesResult {
    targets: Vec<BuildTargetIdentifier>,
}