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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
#![feature(proc_macro)]
#[macro_use]
extern crate enum_primitive;
extern crate serde;
extern crate serde_json;
#[macro_use]
extern crate serde_derive;
use std::collections::HashMap;
use serde::de::Error;
use serde_json::Value;
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct CancelParams {
pub id: String,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct DidChangeTextDocumentParams {
#[serde(rename="textDocument")]
pub text_document: VersionedTextDocumentIdentifier,
#[serde(rename="contentChanges")]
pub content_changes: Vec<TextDocumentContentChangeEvent>,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct TextDocumentIdentifier {
pub uri: String,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct VersionedTextDocumentIdentifier {
pub uri: String,
pub version: u64,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct TextDocumentItem {
pub uri: String,
#[serde(rename="languageId")]
pub language_id: String,
pub version: u64,
pub text: String,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct DidOpenTextDocumentParams {
#[serde(rename="textDocument")]
pub text_document: TextDocumentItem,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct TextDocumentContentChangeEvent {
pub range: Option<Range>,
#[serde(rename="rangeLength")]
pub range_length: Option<u64>,
pub text: String,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct DidCloseTextDocumentParams {
#[serde(rename="textDocument")]
pub text_document: TextDocumentIdentifier,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct DidSaveTextDocumentParams {
#[serde(rename="textDocument")]
pub text_document: TextDocumentIdentifier,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct DidChangeWatchedFilesParams {
pub changes: Vec<FileEvent>,
}
#[derive(Debug, PartialEq, Copy, Clone)]
pub enum FileChangeType {
Created = 1,
Changed = 2,
Deleted = 3,
}
impl serde::Deserialize for FileChangeType {
fn deserialize<D>(deserializer: &mut D) -> Result<Self, D::Error>
where D: serde::Deserializer
{
Ok(match try!(u8::deserialize(deserializer)) {
1 => FileChangeType::Created,
2 => FileChangeType::Changed,
3 => FileChangeType::Deleted,
_ => {
return Err(D::Error::invalid_value("Expected a value of 1, 2 or 3 to deserialze \
to FileChangeType"))
}
})
}
}
impl serde::Serialize for FileChangeType {
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
where S: serde::Serializer
{
serializer.serialize_u8(*self as u8)
}
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct FileEvent {
pub uri: String,
pub typ: FileChangeType,
}
#[derive(Debug, PartialEq, Copy, Clone, Default, Deserialize, Serialize)]
pub struct Position {
pub line: u64,
pub character: u64,
}
#[derive(Debug, PartialEq, Copy, Clone, Default, Deserialize, Serialize)]
pub struct Range {
pub start: Position,
pub end: Position,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct Location {
pub uri: String,
pub range: Range,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct TextDocumentPositionParams {
#[serde(rename="textDocument")]
pub text_document: TextDocumentIdentifier,
pub position: Position,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct InitializeParams {
#[serde(rename="processId")]
pub process_id: u64,
#[serde(rename="rootPath")]
pub root_path: Option<String>,
pub capabilities: ClientCapabilities,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct ClientCapabilities {
_dummy: Option<()>,
}
#[derive(Debug, PartialEq, Default, Deserialize, Serialize)]
pub struct InitializeResult {
pub capabilities: ServerCapabilities,
}
#[derive(Debug, PartialEq, Default, Deserialize, Serialize)]
pub struct InitializeError {
pub retry: bool,
}
#[derive(Debug, PartialEq, Default, Deserialize, Serialize)]
pub struct ServerCapabilities {
#[serde(skip_serializing_if="Option::is_none")]
#[serde(rename="textDocumentSync")]
pub text_document_sync: Option<TextDocumentSyncKind>,
#[serde(skip_serializing_if="Option::is_none")]
#[serde(rename="hoverProvider")]
pub hover_provider: Option<bool>,
#[serde(skip_serializing_if="Option::is_none")]
#[serde(rename="completionProvider")]
pub completion_provider: Option<CompletionOptions>,
#[serde(skip_serializing_if="Option::is_none")]
#[serde(rename="signatureHelpProvider")]
pub signature_help_provider: Option<SignatureHelpOptions>,
#[serde(skip_serializing_if="Option::is_none")]
#[serde(rename="definitionProvider")]
pub definition_provider: Option<bool>,
#[serde(skip_serializing_if="Option::is_none")]
#[serde(rename="referencesProvider")]
pub references_provider: Option<bool>,
#[serde(skip_serializing_if="Option::is_none")]
#[serde(rename="documentHighlightProvider")]
pub document_highlight_provider: Option<bool>,
#[serde(skip_serializing_if="Option::is_none")]
#[serde(rename="documentSymbolProvider")]
pub document_symbol_provider: Option<bool>,
#[serde(skip_serializing_if="Option::is_none")]
#[serde(rename="workspaceSymbolProvider")]
pub workspace_symbol_provider: Option<bool>,
#[serde(skip_serializing_if="Option::is_none")]
#[serde(rename="codeActionProvider")]
pub code_action_provider: Option<bool>,
#[serde(skip_serializing_if="Option::is_none")]
#[serde(rename="codeLensProvider")]
pub code_lens_provider: Option<CodeLensOptions>,
#[serde(skip_serializing_if="Option::is_none")]
#[serde(rename="documentFormattingProvider")]
pub document_formatting_provider: Option<bool>,
#[serde(skip_serializing_if="Option::is_none")]
#[serde(rename="documentRangeFormattingProvider")]
pub document_range_formatting_provider: Option<bool>,
#[serde(skip_serializing_if="Option::is_none")]
#[serde(rename="documentOnTypeFormattingProvider")]
pub document_on_type_formatting_provider: Option<DocumentOnTypeFormattingOptions>,
#[serde(skip_serializing_if="Option::is_none")]
#[serde(rename="renameProvider")]
pub rename_provider: Option<bool>,
}
#[derive(Debug, PartialEq, Clone, Copy)]
pub enum TextDocumentSyncKind {
None = 0,
Full = 1,
Incremental = 2,
}
impl serde::Deserialize for TextDocumentSyncKind {
fn deserialize<D>(deserializer: &mut D) -> Result<Self, D::Error>
where D: serde::Deserializer
{
Ok(match try!(u8::deserialize(deserializer)) {
0 => TextDocumentSyncKind::None,
1 => TextDocumentSyncKind::Full,
2 => TextDocumentSyncKind::Incremental,
_ => {
return Err(D::Error::invalid_value("Expected a value between 1 and 2 (inclusive) \
to deserialize to TextDocumentSyncKind"))
}
})
}
}
impl serde::Serialize for TextDocumentSyncKind {
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
where S: serde::Serializer
{
serializer.serialize_u8(*self as u8)
}
}
#[derive(Debug, PartialEq, Default, Deserialize, Serialize)]
pub struct CompletionOptions {
#[serde(skip_serializing_if="Option::is_none")]
#[serde(rename="resolveProvider")]
pub resolve_provider: Option<bool>,
#[serde(rename="triggerCharacters")]
pub trigger_characters: Vec<String>,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct SignatureHelpOptions {
#[serde(skip_serializing_if="Vec::is_empty")]
#[serde(rename="triggerCharacters")]
pub trigger_characters: Vec<String>,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct CodeLensOptions {
#[serde(rename="resolveProvider")]
pub resolve_provider: Option<bool>,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct DocumentOnTypeFormattingOptions {
#[serde(rename="firstTriggerCharacter")]
pub first_trigger_character: String,
#[serde(skip_serializing_if="Vec::is_empty")]
#[serde(rename="moreTriggerCharacter")]
pub more_trigger_character: Vec<String>,
}
#[derive(Debug, PartialEq, Default, Deserialize, Serialize)]
pub struct TextEdit {
pub range: Range,
#[serde(rename="newText")]
pub new_text: String,
}
#[derive(Debug, PartialEq, Default, Deserialize, Serialize)]
pub struct WorkspaceEdit {
pub changes: HashMap<String, Vec<TextEdit>>,
}
#[derive(Debug, PartialEq, Default, Deserialize, Serialize)]
pub struct CompletionList {
#[serde(rename="isIncomplete")]
pub is_incomplete: bool,
pub items: Vec<CompletionItem>,
}
#[derive(Debug, PartialEq, Default, Deserialize, Serialize)]
pub struct CompletionItem {
pub label: String,
#[serde(skip_serializing_if="Option::is_none")]
pub kind: Option<CompletionItemKind>,
#[serde(skip_serializing_if="Option::is_none")]
pub detail: Option<String>,
#[serde(skip_serializing_if="Option::is_none")]
pub documentation: Option<String>,
#[serde(skip_serializing_if="Option::is_none")]
#[serde(rename="sortText")]
pub sort_text: Option<String>,
#[serde(skip_serializing_if="Option::is_none")]
#[serde(rename="filterText")]
pub filter_text: Option<String>,
#[serde(skip_serializing_if="Option::is_none")]
#[serde(rename="insertText")]
pub insert_text: Option<String>,
#[serde(skip_serializing_if="Option::is_none")]
#[serde(rename="textEdit")]
pub text_edit: Option<TextEdit>,
#[serde(skip_serializing_if="Option::is_none")]
pub data: Option<Value>,
}
enum_from_primitive!{
#[derive(Debug, PartialEq, Clone, Copy)]
pub enum CompletionItemKind {
Text = 1,
Method = 2,
Function = 3,
Constructor = 4,
Field = 5,
Variable = 6,
Class = 7,
Interface = 8,
Module = 9,
Property = 10,
Unit = 11,
Value = 12,
Enum = 13,
Keyword = 14,
Snippet = 15,
Color = 16,
File = 17,
Reference = 18,
}
}
impl serde::Deserialize for CompletionItemKind {
fn deserialize<D>(deserializer: &mut D) -> Result<Self, D::Error>
where D: serde::Deserializer
{
use enum_primitive::FromPrimitive;
let i = try!(u8::deserialize(deserializer));
CompletionItemKind::from_u8(i).ok_or_else(|| {
D::Error::invalid_value("Expected a value between 1 and 18 (inclusive) to deserialize \
to CompletionItemKind")
})
}
}
impl serde::Serialize for CompletionItemKind {
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
where S: serde::Serializer
{
serializer.serialize_u8(*self as u8)
}
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct Hover {
pub contents: Vec<MarkedString>,
pub range: Option<Range>,
}
#[derive(Debug, PartialEq)]
pub enum MarkedString {
String(String),
LanguageString { language: String, value: String },
}
impl serde::Deserialize for MarkedString {
fn deserialize<D>(deserializer: &mut D) -> Result<Self, D::Error>
where D: serde::Deserializer
{
String::deserialize(deserializer)
.map(MarkedString::String)
.or_else(|_| {
use std::borrow::Cow;
#[derive(Deserialize, Serialize)]
struct Variant<'s> {
language: Cow<'s, str>,
value: Cow<'s, str>,
}
Variant::deserialize(deserializer).map(|variant| {
MarkedString::LanguageString {
language: variant.language.into_owned(),
value: variant.value.into_owned(),
}
})
})
}
}
impl serde::Serialize for MarkedString {
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
where S: serde::Serializer
{
match *self {
MarkedString::String(ref s) => serializer.serialize_str(s),
MarkedString::LanguageString { ref language, ref value } => {
#[derive(Serialize)]
struct Variant<'s> {
language: &'s str,
value: &'s str,
}
Variant {
language: language,
value: value,
}
.serialize(serializer)
}
}
}
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct SignatureHelp {
pub signatures: Vec<SignatureInformation>,
#[serde(rename="activeSignature")]
pub active_signature: Option<u64>,
#[serde(rename="activeParameter")]
pub active_parameter: Option<u64>,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct SignatureInformation {
pub label: String,
pub documentation: String,
#[serde(skip_serializing_if="Vec::is_empty")]
pub parameters: Vec<ParameterInformation>,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct ParameterInformation {
pub label: String,
#[serde(skip_serializing_if="String::is_empty")]
pub documentation: String,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct ReferenceParams {
#[serde(rename="textDocument")]
pub text_document: TextDocumentIdentifier,
pub position: Position,
pub context: ReferenceContext,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct ReferenceContext {
#[serde(rename="includeDeclaration")]
pub include_declaration: bool,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct DocumentHighlight {
pub range: Range,
pub kind: Option<DocumentHighlightKind>,
}
#[derive(Debug, PartialEq, Copy, Clone)]
pub enum DocumentHighlightKind {
Text = 1,
Read = 2,
Write = 3,
}
impl serde::Deserialize for DocumentHighlightKind {
fn deserialize<D>(deserializer: &mut D) -> Result<Self, D::Error>
where D: serde::Deserializer
{
Ok(match try!(u8::deserialize(deserializer)) {
1 => DocumentHighlightKind::Text,
2 => DocumentHighlightKind::Read,
3 => DocumentHighlightKind::Write,
_ => {
return Err(D::Error::invalid_value("Expected a value of 1, 2, or 3 to \
deserialze to DocumentHighlightKiny"))
}
})
}
}
impl serde::Serialize for DocumentHighlightKind {
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
where S: serde::Serializer
{
serializer.serialize_u8(*self as u8)
}
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct DocumentSymbolParams {
#[serde(rename="textDocument")]
pub text_document: TextDocumentIdentifier,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct SymbolInformation {
pub name: String,
pub kind: SymbolKind,
pub location: Location,
#[serde(rename="containerName")]
pub container_name: String,
}
enum_from_primitive!{
#[derive(Debug, PartialEq, Copy, Clone)]
pub enum SymbolKind {
File = 1,
Module = 2,
Namespace = 3,
Package = 4,
Class = 5,
Method = 6,
Property = 7,
Field = 8,
Constructor = 9,
Enum = 10,
Interface = 11,
Function = 12,
Variable = 13,
Constant = 14,
String = 15,
Number = 16,
Boolean = 17,
Array = 18,
}
}
impl serde::Deserialize for SymbolKind {
fn deserialize<D>(deserializer: &mut D) -> Result<Self, D::Error>
where D: serde::Deserializer
{
use enum_primitive::FromPrimitive;
let i = try!(u8::deserialize(deserializer));
SymbolKind::from_u8(i).ok_or_else(|| {
D::Error::invalid_value("Expected a value between 1 and 18 (inclusive) to deserialize \
to SymbolKind")
})
}
}
impl serde::Serialize for SymbolKind {
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
where S: serde::Serializer
{
serializer.serialize_u8(*self as u8)
}
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct WorkspaceSymbolParams {
pub query: String,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct CodeActionParams {
pub text_document: TextDocumentIdentifier,
pub range: Range,
pub context: CodeActionContext,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct CodeActionContext {
pub diagnostics: Vec<Diagnostic>,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct CodeLensParams {
#[serde(rename="textDocument")]
pub text_document: TextDocumentIdentifier,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct CodeLens {
pub range: Range,
pub command: Option<Command>,
pub data: Option<Value>,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct RenameParams {
#[serde(rename="textDocument")]
pub text_document: TextDocumentIdentifier,
pub position: Position,
#[serde(rename="newName")]
pub new_name: String,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct ShowMessageParams {
#[serde(rename="type")]
pub typ: MessageType,
pub message: String,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct ShowMessageRequestParams {
#[serde(rename="type")]
pub typ: MessageType,
pub message: String,
#[serde(skip_serializing_if="Vec::is_empty")]
pub actions: Vec<MessageActionItem>,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct MessageActionItem {
pub title: String,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct LogMessageParams {
#[serde(rename="type")]
pub typ: MessageType,
pub message: String,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct DidChangeConfigurationParams {
pub settings: Value,
}
#[derive(Debug, PartialEq, Clone, Copy)]
pub enum MessageType {
Error = 1,
Warning = 2,
Info = 3,
Log = 4,
}
impl serde::Deserialize for MessageType {
fn deserialize<D>(deserializer: &mut D) -> Result<Self, D::Error>
where D: serde::Deserializer
{
Ok(match try!(u8::deserialize(deserializer)) {
1 => MessageType::Error,
2 => MessageType::Warning,
3 => MessageType::Info,
4 => MessageType::Log,
_ => {
return Err(D::Error::invalid_value("Expected a value of 1, 2, 3 or 4 to \
deserialze to MessageType"))
}
})
}
}
impl serde::Serialize for MessageType {
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
where S: serde::Serializer
{
serializer.serialize_u8(*self as u8)
}
}
#[derive(Debug, PartialEq, Default, Deserialize, Serialize)]
pub struct PublishDiagnosticsParams {
pub uri: String,
pub diagnostics: Vec<Diagnostic>,
}
#[derive(Debug, PartialEq, Default, Deserialize, Serialize)]
pub struct Diagnostic {
pub range: Range,
pub severity: Option<DiagnosticSeverity>,
pub code: String,
pub source: Option<String>,
pub message: String,
}
#[derive(Debug, PartialEq, Clone, Copy)]
pub enum DiagnosticSeverity {
Error = 1,
Warning = 2,
Information = 3,
Hint = 4,
}
impl serde::Deserialize for DiagnosticSeverity {
fn deserialize<D>(deserializer: &mut D) -> Result<Self, D::Error>
where D: serde::Deserializer
{
Ok(match try!(u8::deserialize(deserializer)) {
1 => DiagnosticSeverity::Error,
2 => DiagnosticSeverity::Warning,
3 => DiagnosticSeverity::Information,
4 => DiagnosticSeverity::Hint,
_ => {
return Err(D::Error::invalid_value("Expected a value of 1, 2, 3 or 4 to \
deserialze to DiagnosticSeverity"))
}
})
}
}
impl serde::Serialize for DiagnosticSeverity {
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
where S: serde::Serializer
{
serializer.serialize_u8(*self as u8)
}
}
#[derive(Debug, PartialEq, Default, Deserialize, Serialize)]
pub struct Command {
pub title: String,
pub command: String,
#[serde(skip_serializing_if="Vec::is_empty")]
pub arguments: Vec<Value>,
}