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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
use super::BuildTargetIdentifier;
use serde::{Deserialize, Serialize};
/// The build target resources request is sent from the client to the server to query for the list
/// of resources of a given list of build targets.
///
/// A resource is a data dependency required to be present in the runtime classpath when a build
/// target is run or executed. The server communicates during the initialize handshake whether this
/// method is supported or not.
///
/// This request can be used by a client to highlight the resources in a project view, for example.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct BuildTargetResources {
    targets: Vec<BuildTargetIdentifier>,
}

impl BuildTargetResources {
    pub fn new(targets: Vec<BuildTargetIdentifier>) -> Self {
        Self { targets }
    }

    /// Get a reference to the resources params's targets.
    pub fn targets(&self) -> &[BuildTargetIdentifier] {
        self.targets.as_ref()
    }

    /// Set the resources params's targets.
    pub fn set_targets(&mut self, targets: Vec<BuildTargetIdentifier>) {
        self.targets = targets;
    }

    /// Get a mutable reference to the resources params's targets.
    pub fn targets_mut(&mut self) -> &mut Vec<BuildTargetIdentifier> {
        &mut self.targets
    }
}

#[derive(Default, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct BuildTargetResourcesResult {
    items: Vec<Resources>,
}

impl BuildTargetResourcesResult {
    pub fn new(items: Vec<Resources>) -> Self {
        Self { items }
    }

    /// Get a reference to the bsp resources result's items.
    pub fn items(&self) -> &[Resources] {
        self.items.as_ref()
    }

    /// Get a mutable reference to the bsp resources result's items.
    pub fn items_mut(&mut self) -> &mut Vec<Resources> {
        &mut self.items
    }
}

#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct Resources {
    target: BuildTargetIdentifier,
    /// List of resource files.
    resources: Vec<String>,
}

impl Resources {
    pub fn new(target: BuildTargetIdentifier, resources: Vec<String>) -> Self {
        Self { target, resources }
    }

    /// Set the bsp resources item's target.
    pub fn set_target(&mut self, target: BuildTargetIdentifier) {
        self.target = target;
    }

    /// Get a reference to the bsp resources item's target.
    pub fn target(&self) -> &BuildTargetIdentifier {
        &self.target
    }

    /// Set the bsp resources item's resources.
    pub fn set_resources(&mut self, resources: Vec<String>) {
        self.resources = resources;
    }

    /// Get a reference to the bsp resources item's resources.
    pub fn resources(&self) -> &[String] {
        self.resources.as_ref()
    }
}