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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
use super::BuildTargetIdentifier;
use serde::{Deserialize, Serialize};
use serde_json::Value;

/// The test build target request is sent from the client to the server to test the given list of
/// build targets. The server communicates during the initialize handshake whether this method is
/// supported or not.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct BuildTargetTest {
    /// The build target to run.
    target: BuildTargetIdentifier,

    /// A unique identifier generated by the client to identify this request.
    ///  * The server may include this id in triggered notifications or responses.
    #[serde(skip_serializing_if = "Option::is_none")]
    origin_id: Option<String>,

    /// Optional arguments to the executed application.
    #[serde(skip_serializing_if = "Option::is_none")]
    arguments: Option<String>,

    /// Kind of data to expect in the data field. If this field is not set, the kind of data is not specified.
    #[serde(skip_serializing_if = "Option::is_none")]
    data_kind: Option<String>,

    /// Language-specific metadata for this execution.
    ///  * See <https://github.com/build-server-protocol/build-server-protocol/blob/9dce5849816483b5b0a2baed24f83bf101546184/bsp4j/src/main/xtend-gen/ch/epfl/scala/bsp4j/ScalaTestParams.java>
    #[serde(skip_serializing_if = "Option::is_none")]
    data: Option<Value>,
}

impl BuildTargetTest {
    pub fn new(
        target: BuildTargetIdentifier,
        origin_id: Option<String>,
        arguments: Option<String>,
        data_kind: Option<String>,
        data: Option<Value>,
    ) -> Self {
        Self {
            target,
            origin_id,
            arguments,
            data_kind,
            data,
        }
    }
    pub fn new_simple(target: BuildTargetIdentifier) -> Self {
        Self {
            target,
            origin_id: None,
            arguments: None,
            data_kind: None,
            data: None,
        }
    }

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

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

    /// Get a reference to the bsp btrun params's origin id.
    pub fn origin_id(&self) -> Option<&String> {
        self.origin_id.as_ref()
    }

    /// Set the bsp btrun params's origin id.
    pub fn set_origin_id(&mut self, origin_id: Option<String>) {
        self.origin_id = origin_id;
    }

    /// Get a reference to the bsp btrun params's arguments.
    pub fn arguments(&self) -> Option<&String> {
        self.arguments.as_ref()
    }

    /// Set the bsp btrun params's arguments.
    pub fn set_arguments(&mut self, arguments: Option<String>) {
        self.arguments = arguments;
    }

    /// Get a reference to the bsp btrun params's data kind.
    pub fn data_kind(&self) -> Option<&String> {
        self.data_kind.as_ref()
    }

    /// Set the bsp btrun params's data kind.
    pub fn set_data_kind(&mut self, data_kind: Option<String>) {
        self.data_kind = data_kind;
    }

    /// Get a reference to the bsp btrun params's data.
    pub fn data(&self) -> Option<&Value> {
        self.data.as_ref()
    }

    /// Set the bsp btrun params's data.
    pub fn set_data(&mut self, data: Option<Value>) {
        self.data = data;
    }
}

/// Note that an empty run request is valid. Run will be executed in the target as specified in the build tool.
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct BuildTargetTestResult {
    /// An optional request id to know the origin of this report.
    #[serde(skip_serializing_if = "Option::is_none")]
    origin_id: Option<String>,

    /// A status code for the execution.
    status_code: usize,

    /// Kind of data to expect in the `data` field. If this field is not set, the kind of data is not specified.
    #[serde(skip_serializing_if = "Option::is_none")]
    data_kind: Option<String>,

    /// A field containing language-specific information, like products
    ///    * of compilation or compiler-specific metadata the client needs to know.
    #[serde(skip_serializing_if = "Option::is_none")]
    data: Option<Value>,
}

impl BuildTargetTestResult {
    pub fn new(
        origin_id: Option<String>,
        status_code: usize,
        data_kind: Option<String>,
        data: Option<Value>,
    ) -> Self {
        Self {
            origin_id,
            status_code,
            data_kind,
            data,
        }
    }
    pub fn new_simple(status_code: usize) -> Self {
        Self {
            origin_id: None,
            status_code,
            data_kind: None,
            data: None,
        }
    }

    /// Get a reference to the bsp btrun result's origin id.
    pub fn origin_id(&self) -> Option<&String> {
        self.origin_id.as_ref()
    }

    /// Get the bsp btrun result's status code.
    pub fn status_code(&self) -> usize {
        self.status_code
    }

    /// Set the bsp btrun result's origin id.
    pub fn set_origin_id(&mut self, origin_id: Option<String>) {
        self.origin_id = origin_id;
    }

    /// Set the bsp btrun result's status code.
    pub fn set_status_code(&mut self, status_code: usize) {
        self.status_code = status_code;
    }

    /// Set the bsp btcompile result's data kind.
    pub fn set_data_kind(&mut self, data_kind: Option<String>) {
        self.data_kind = data_kind;
    }

    /// Get a reference to the bsp btcompile result's data kind.
    pub fn data_kind(&self) -> Option<&String> {
        self.data_kind.as_ref()
    }

    /// Set the bsp btcompile result's data.
    pub fn set_data(&mut self, data: Option<Value>) {
        self.data = data;
    }

    /// Get a reference to the bsp btcompile result's data.
    pub fn data(&self) -> Option<&Value> {
        self.data.as_ref()
    }
}