/
metaModel.go
1033 lines (891 loc) · 27.4 KB
/
metaModel.go
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
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT.
package main
import (
"encoding/json"
"fmt"
"reflect"
)
// Represents an `and`type (e.g. TextDocumentParams & WorkDoneProgressParams`).
type AndType struct {
// Items corresponds to the JSON schema field "items".
Items []AndTypeItemsElem `json:"items"`
// Kind corresponds to the JSON schema field "kind".
Kind string `json:"kind"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *AndType) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["items"]; !ok || v == nil {
return fmt.Errorf("field items: required")
}
if v, ok := raw["kind"]; !ok || v == nil {
return fmt.Errorf("field kind: required")
}
type Plain AndType
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = AndType(plain)
return nil
}
type ArrayTypeElement interface{}
// Represents an array type (e.g. `TextDocument[]`).
type ArrayType struct {
// Element corresponds to the JSON schema field "element".
Element ArrayTypeElement `json:"element"`
// Kind corresponds to the JSON schema field "kind".
Kind string `json:"kind"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *ArrayType) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["element"]; !ok || v == nil {
return fmt.Errorf("field element: required")
}
if v, ok := raw["kind"]; !ok || v == nil {
return fmt.Errorf("field kind: required")
}
type Plain ArrayType
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = ArrayType(plain)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *TypeKind) UnmarshalJSON(b []byte) error {
var v string
if err := json.Unmarshal(b, &v); err != nil {
return err
}
var ok bool
for _, expected := range enumValues_TypeKind {
if reflect.DeepEqual(v, expected) {
ok = true
break
}
}
if !ok {
return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_TypeKind, v)
}
*j = TypeKind(v)
return nil
}
const BaseTypesURI BaseTypes = "URI"
const BaseTypesDocumentUri BaseTypes = "DocumentUri"
const BaseTypesInteger BaseTypes = "integer"
const BaseTypesUinteger BaseTypes = "uinteger"
const BaseTypesDecimal BaseTypes = "decimal"
const BaseTypesRegExp BaseTypes = "RegExp"
type AndTypeItemsElem interface{}
const BaseTypesBoolean BaseTypes = "boolean"
const BaseTypesNull BaseTypes = "null"
// Represents a base type like `string` or `DocumentUri`.
type BaseType struct {
// Kind corresponds to the JSON schema field "kind".
Kind string `json:"kind"`
// Name corresponds to the JSON schema field "name".
Name BaseTypes `json:"name"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *BaseType) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["kind"]; !ok || v == nil {
return fmt.Errorf("field kind: required")
}
if v, ok := raw["name"]; !ok || v == nil {
return fmt.Errorf("field name: required")
}
type Plain BaseType
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = BaseType(plain)
return nil
}
type BaseTypes string
// UnmarshalJSON implements json.Unmarshaler.
func (j *TupleType) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["items"]; !ok || v == nil {
return fmt.Errorf("field items: required")
}
if v, ok := raw["kind"]; !ok || v == nil {
return fmt.Errorf("field kind: required")
}
type Plain TupleType
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = TupleType(plain)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *BaseTypes) UnmarshalJSON(b []byte) error {
var v string
if err := json.Unmarshal(b, &v); err != nil {
return err
}
var ok bool
for _, expected := range enumValues_BaseTypes {
if reflect.DeepEqual(v, expected) {
ok = true
break
}
}
if !ok {
return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_BaseTypes, v)
}
*j = BaseTypes(v)
return nil
}
const BaseTypes_URI BaseTypes = "URI"
const BaseTypes_DocumentUri BaseTypes = "DocumentUri"
const BaseTypes_Integer BaseTypes = "integer"
const BaseTypes_Uinteger BaseTypes = "uinteger"
const BaseTypes_Decimal BaseTypes = "decimal"
const BaseTypes_RegExp BaseTypes = "RegExp"
const BaseTypes_String BaseTypes = "string"
const BaseTypes_Boolean BaseTypes = "boolean"
const BaseTypes_Null BaseTypes = "null"
// Represents a boolean literal type (e.g. `kind: true`).
type BooleanLiteralType struct {
// Kind corresponds to the JSON schema field "kind".
Kind string `json:"kind"`
// Value corresponds to the JSON schema field "value".
Value bool `json:"value"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *BooleanLiteralType) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["kind"]; !ok || v == nil {
return fmt.Errorf("field kind: required")
}
if v, ok := raw["value"]; !ok || v == nil {
return fmt.Errorf("field value: required")
}
type Plain BooleanLiteralType
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = BooleanLiteralType(plain)
return nil
}
type EnumerationTypeName string
// UnmarshalJSON implements json.Unmarshaler.
func (j *StructureLiteralType) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["kind"]; !ok || v == nil {
return fmt.Errorf("field kind: required")
}
if v, ok := raw["value"]; !ok || v == nil {
return fmt.Errorf("field value: required")
}
type Plain StructureLiteralType
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = StructureLiteralType(plain)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *EnumerationTypeName) UnmarshalJSON(b []byte) error {
var v string
if err := json.Unmarshal(b, &v); err != nil {
return err
}
var ok bool
for _, expected := range enumValues_EnumerationTypeName {
if reflect.DeepEqual(v, expected) {
ok = true
break
}
}
if !ok {
return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_EnumerationTypeName, v)
}
*j = EnumerationTypeName(v)
return nil
}
const EnumerationTypeNameString EnumerationTypeName = "string"
const EnumerationTypeNameInteger EnumerationTypeName = "integer"
const EnumerationTypeNameUinteger EnumerationTypeName = "uinteger"
type EnumerationType struct {
// Kind corresponds to the JSON schema field "kind".
Kind string `json:"kind"`
// Name corresponds to the JSON schema field "name".
Name EnumerationTypeName `json:"name"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *EnumerationType) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["kind"]; !ok || v == nil {
return fmt.Errorf("field kind: required")
}
if v, ok := raw["name"]; !ok || v == nil {
return fmt.Errorf("field name: required")
}
type Plain EnumerationType
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = EnumerationType(plain)
return nil
}
// Defines an enumeration entry.
type EnumerationEntry struct {
// An optional documentation.
Documentation *string `json:"documentation,omitempty"`
// The name of the enum item.
Name string `json:"name"`
// Whether this is a proposed enumeration entry. If omitted, the enumeration entry
// is final.
Proposed *bool `json:"proposed,omitempty"`
// Since when (release number) this enumeration entry is available. Is undefined
// if not known.
Since *string `json:"since,omitempty"`
// The value.
Value interface{} `json:"value"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *EnumerationEntry) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["name"]; !ok || v == nil {
return fmt.Errorf("field name: required")
}
if v, ok := raw["value"]; !ok || v == nil {
return fmt.Errorf("field value: required")
}
type Plain EnumerationEntry
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = EnumerationEntry(plain)
return nil
}
// Defines an enumeration.
type Enumeration struct {
// An optional documentation.
Documentation *string `json:"documentation,omitempty"`
// The name of the enumeration.
Name string `json:"name"`
// Whether this is a proposed enumeration. If omitted, the enumeration is final.
Proposed *bool `json:"proposed,omitempty"`
// Since when (release number) this enumeration is available. Is undefined if not
// known.
Since *string `json:"since,omitempty"`
// Whether the enumeration supports custom values (e.g. values which are not part
// of the set defined in `values`). If omitted no custom values are supported.
SupportsCustomValues *bool `json:"supportsCustomValues,omitempty"`
// The type of the elements.
Type EnumerationType `json:"type"`
// The enum values.
Values []EnumerationEntry `json:"values"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *Enumeration) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["name"]; !ok || v == nil {
return fmt.Errorf("field name: required")
}
if v, ok := raw["type"]; !ok || v == nil {
return fmt.Errorf("field type: required")
}
if v, ok := raw["values"]; !ok || v == nil {
return fmt.Errorf("field values: required")
}
type Plain Enumeration
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = Enumeration(plain)
return nil
}
type IntegerLiteralType struct {
// Represents an integer literal type (e.g. `kind: 1`).
Kind string `json:"kind"`
// Value corresponds to the JSON schema field "value".
Value float64 `json:"value"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *IntegerLiteralType) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["kind"]; !ok || v == nil {
return fmt.Errorf("field kind: required")
}
if v, ok := raw["value"]; !ok || v == nil {
return fmt.Errorf("field value: required")
}
type Plain IntegerLiteralType
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = IntegerLiteralType(plain)
return nil
}
// Represents a type that can be used as a key in a map type. If a reference type
// is used then the type must either resolve to a `string` or `integer` type. (e.g.
// `type ChangeAnnotationIdentifier === string`).
type MapKeyType interface{}
type MapTypeKey interface{}
type MapTypeValue interface{}
// Represents a JSON object map (e.g. `interface Map<K extends string | integer, V>
// { [key: K] => V; }`).
type MapType struct {
// Key corresponds to the JSON schema field "key".
Key MapTypeKey `json:"key"`
// Kind corresponds to the JSON schema field "kind".
Kind string `json:"kind"`
// Value corresponds to the JSON schema field "value".
Value MapTypeValue `json:"value"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *MapType) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["key"]; !ok || v == nil {
return fmt.Errorf("field key: required")
}
if v, ok := raw["kind"]; !ok || v == nil {
return fmt.Errorf("field kind: required")
}
if v, ok := raw["value"]; !ok || v == nil {
return fmt.Errorf("field value: required")
}
type Plain MapType
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = MapType(plain)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *StructureLiteral) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["properties"]; !ok || v == nil {
return fmt.Errorf("field properties: required")
}
type Plain StructureLiteral
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = StructureLiteral(plain)
return nil
}
const MessageDirectionClientToServer MessageDirection = "clientToServer"
const MessageDirectionServerToClient MessageDirection = "serverToClient"
const MessageDirectionBoth MessageDirection = "both"
// UnmarshalJSON implements json.Unmarshaler.
func (j *StringLiteralType) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["kind"]; !ok || v == nil {
return fmt.Errorf("field kind: required")
}
if v, ok := raw["value"]; !ok || v == nil {
return fmt.Errorf("field value: required")
}
type Plain StringLiteralType
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = StringLiteralType(plain)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *MetaData) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["version"]; !ok || v == nil {
return fmt.Errorf("field version: required")
}
type Plain MetaData
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = MetaData(plain)
return nil
}
const BaseTypesString BaseTypes = "string"
// UnmarshalJSON implements json.Unmarshaler.
func (j *ReferenceType) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["kind"]; !ok || v == nil {
return fmt.Errorf("field kind: required")
}
if v, ok := raw["name"]; !ok || v == nil {
return fmt.Errorf("field name: required")
}
type Plain ReferenceType
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = ReferenceType(plain)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *MessageDirection) UnmarshalJSON(b []byte) error {
var v string
if err := json.Unmarshal(b, &v); err != nil {
return err
}
var ok bool
for _, expected := range enumValues_MessageDirection {
if reflect.DeepEqual(v, expected) {
ok = true
break
}
}
if !ok {
return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_MessageDirection, v)
}
*j = MessageDirection(v)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *OrType) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["items"]; !ok || v == nil {
return fmt.Errorf("field items: required")
}
if v, ok := raw["kind"]; !ok || v == nil {
return fmt.Errorf("field kind: required")
}
type Plain OrType
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = OrType(plain)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *MetaModel) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["enumerations"]; !ok || v == nil {
return fmt.Errorf("field enumerations: required")
}
if v, ok := raw["metaData"]; !ok || v == nil {
return fmt.Errorf("field metaData: required")
}
if v, ok := raw["notifications"]; !ok || v == nil {
return fmt.Errorf("field notifications: required")
}
if v, ok := raw["requests"]; !ok || v == nil {
return fmt.Errorf("field requests: required")
}
if v, ok := raw["structures"]; !ok || v == nil {
return fmt.Errorf("field structures: required")
}
if v, ok := raw["typeAliases"]; !ok || v == nil {
return fmt.Errorf("field typeAliases: required")
}
type Plain MetaModel
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = MetaModel(plain)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *TypeAlias) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["name"]; !ok || v == nil {
return fmt.Errorf("field name: required")
}
if v, ok := raw["type"]; !ok || v == nil {
return fmt.Errorf("field type: required")
}
type Plain TypeAlias
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = TypeAlias(plain)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *Structure) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["name"]; !ok || v == nil {
return fmt.Errorf("field name: required")
}
if v, ok := raw["properties"]; !ok || v == nil {
return fmt.Errorf("field properties: required")
}
type Plain Structure
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = Structure(plain)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *Property) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["name"]; !ok || v == nil {
return fmt.Errorf("field name: required")
}
if v, ok := raw["type"]; !ok || v == nil {
return fmt.Errorf("field type: required")
}
type Plain Property
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = Property(plain)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *Notification) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["messageDirection"]; !ok || v == nil {
return fmt.Errorf("field messageDirection: required")
}
if v, ok := raw["method"]; !ok || v == nil {
return fmt.Errorf("field method: required")
}
type Plain Notification
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = Notification(plain)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *Request) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["messageDirection"]; !ok || v == nil {
return fmt.Errorf("field messageDirection: required")
}
if v, ok := raw["method"]; !ok || v == nil {
return fmt.Errorf("field method: required")
}
if v, ok := raw["result"]; !ok || v == nil {
return fmt.Errorf("field result: required")
}
type Plain Request
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = Request(plain)
return nil
}
type MessageDirection string
const MessageDirection_Both MessageDirection = "both"
const MessageDirection_ClientToServer MessageDirection = "clientToServer"
const MessageDirection_ServerToClient MessageDirection = "serverToClient"
type MetaData struct {
// The protocol version.
Version string `json:"version"`
}
// The actual meta model.
type MetaModel struct {
// The enumerations.
Enumerations []Enumeration `json:"enumerations"`
// Additional meta data.
MetaData MetaData `json:"metaData"`
// The notifications.
Notifications []Notification `json:"notifications"`
// The requests.
Requests []Request `json:"requests"`
// The structures.
Structures []Structure `json:"structures"`
// The type aliases.
TypeAliases []TypeAlias `json:"typeAliases"`
}
// Represents a LSP notification
type Notification struct {
// An optional documentation;
Documentation *string `json:"documentation,omitempty"`
// The direction in which this notification is sent in the protocol.
MessageDirection MessageDirection `json:"messageDirection"`
// The request's method name.
Method string `json:"method"`
// The parameter type(s) if any.
Params interface{} `json:"params,omitempty"`
// Whether this is a proposed notification. If omitted the notification is final.
Proposed *bool `json:"proposed,omitempty"`
// Optional a dynamic registration method if it different from the request's
// method.
RegistrationMethod *string `json:"registrationMethod,omitempty"`
// Optional registration options if the notification supports dynamic
// registration.
RegistrationOptions NotificationRegistrationOptions `json:"registrationOptions,omitempty"`
// Since when (release number) this notification is available. Is undefined if not
// known.
Since *string `json:"since,omitempty"`
}
// Optional registration options if the notification supports dynamic registration.
type NotificationRegistrationOptions interface{}
// Represents an `or` type (e.g. `Location | LocationLink`).
type OrType struct {
// Items corresponds to the JSON schema field "items".
Items []OrTypeItemsElem `json:"items"`
// Kind corresponds to the JSON schema field "kind".
Kind string `json:"kind"`
}
type OrTypeItemsElem interface{}
// Represents an object property.
type Property struct {
// An optional documentation.
Documentation *string `json:"documentation,omitempty"`
// The property name;
Name string `json:"name"`
// Whether the property is optional. If omitted, the property is mandatory.
Optional *bool `json:"optional,omitempty"`
// Whether this is a proposed property. If omitted, the structure is final.
Proposed *bool `json:"proposed,omitempty"`
// Since when (release number) this property is available. Is undefined if not
// known.
Since *string `json:"since,omitempty"`
// The type of the property
Type PropertyType `json:"type"`
}
// The type of the property
type PropertyType interface{}
// Represents a reference to another type (e.g. `TextDocument`). This is either a
// `Structure`, a `Enumeration` or a `TypeAlias` in the same meta model.
type ReferenceType struct {
// Kind corresponds to the JSON schema field "kind".
Kind string `json:"kind"`
// Name corresponds to the JSON schema field "name".
Name string `json:"name"`
}
// Represents a LSP request
type Request struct {
// An optional documentation;
Documentation *string `json:"documentation,omitempty"`
// An optional error data type.
ErrorData RequestErrorData `json:"errorData,omitempty"`
// The direction in which this request is sent in the protocol.
MessageDirection MessageDirection `json:"messageDirection"`
// The request's method name.
Method string `json:"method"`
// The parameter type(s) if any.
Params interface{} `json:"params,omitempty"`
// Optional partial result type if the request supports partial result reporting.
PartialResult RequestPartialResult `json:"partialResult,omitempty"`
// Whether this is a proposed feature. If omitted the feature is final.
Proposed *bool `json:"proposed,omitempty"`
// Optional a dynamic registration method if it different from the request's
// method.
RegistrationMethod *string `json:"registrationMethod,omitempty"`
// Optional registration options if the request supports dynamic registration.
RegistrationOptions RequestRegistrationOptions `json:"registrationOptions,omitempty"`
// The result type.
Result RequestResult `json:"result"`
// Since when (release number) this request is available. Is undefined if not
// known.
Since *string `json:"since,omitempty"`
}
// An optional error data type.
type RequestErrorData interface{}
// Optional partial result type if the request supports partial result reporting.
type RequestPartialResult interface{}
// Optional registration options if the request supports dynamic registration.
type RequestRegistrationOptions interface{}
// The result type.
type RequestResult interface{}
// Represents a string literal type (e.g. `kind: 'rename'`).
type StringLiteralType struct {
// Kind corresponds to the JSON schema field "kind".
Kind string `json:"kind"`
// Value corresponds to the JSON schema field "value".
Value string `json:"value"`
}
// Defines the structure of an object literal.
type Structure struct {
// An optional documentation;
Documentation *string `json:"documentation,omitempty"`
// Structures extended from. This structures form a polymorphic type hierarchy.
Extends []StructureExtendsElem `json:"extends,omitempty"`
// Structures to mix in. The properties of these structures are `copied` into this
// structure. Mixins don't form a polymorphic type hierarchy in LSP.
Mixins []StructureMixinsElem `json:"mixins,omitempty"`
// The name of the structure.
Name string `json:"name"`
// The properties.
Properties []Property `json:"properties"`
// Whether this is a proposed structure. If omitted, the structure is final.
Proposed *bool `json:"proposed,omitempty"`
// Since when (release number) this structure is available. Is undefined if not
// known.
Since *string `json:"since,omitempty"`
}
type StructureExtendsElem interface{}
// Defines a unnamed structure of an object literal.
type StructureLiteral struct {
// An optional documentation.
Documentation *string `json:"documentation,omitempty"`
// The properties.
Properties []Property `json:"properties"`
// Whether this is a proposed structure. If omitted, the structure is final.
Proposed *bool `json:"proposed,omitempty"`
// Since when (release number) this structure is available. Is undefined if not
// known.
Since *string `json:"since,omitempty"`
}
// Represents a literal structure (e.g. `property: { start: uinteger; end:
// uinteger; }`).
type StructureLiteralType struct {
// Kind corresponds to the JSON schema field "kind".
Kind string `json:"kind"`
// Value corresponds to the JSON schema field "value".
Value StructureLiteral `json:"value"`
}
type StructureMixinsElem interface{}
// Represents a `tuple` type (e.g. `[integer, integer]`).
type TupleType struct {
// Items corresponds to the JSON schema field "items".
Items []TupleTypeItemsElem `json:"items"`
// Kind corresponds to the JSON schema field "kind".
Kind string `json:"kind"`
}
type TupleTypeItemsElem interface{}
type Type interface{}
// Defines a type alias. (e.g. `type Definition = Location | LocationLink`)
type TypeAlias struct {
// An optional documentation.
Documentation *string `json:"documentation,omitempty"`
// The name of the type alias.
Name string `json:"name"`
// Whether this is a proposed type alias. If omitted, the type alias is final.
Proposed *bool `json:"proposed,omitempty"`
// Since when (release number) this structure is available. Is undefined if not
// known.
Since *string `json:"since,omitempty"`
// The aliased type.
Type TypeAliasType `json:"type"`
}
// The aliased type.
type TypeAliasType interface{}
type TypeKind string
const TypeKindAnd TypeKind = "and"
const TypeKindArray TypeKind = "array"
const TypeKindBase TypeKind = "base"
const TypeKindBooleanLiteral TypeKind = "booleanLiteral"
const TypeKindIntegerLiteral TypeKind = "integerLiteral"
const TypeKindLiteral TypeKind = "literal"
const TypeKindMap TypeKind = "map"
const TypeKindOr TypeKind = "or"
const TypeKindReference TypeKind = "reference"
const TypeKindStringLiteral TypeKind = "stringLiteral"
const TypeKindTuple TypeKind = "tuple"
var enumValues_BaseTypes = []interface{}{