|
5 | 5 | "encoding/base64"
|
6 | 6 | "encoding/binary"
|
7 | 7 | "encoding/json"
|
| 8 | + "errors" |
8 | 9 | "strings"
|
9 | 10 | )
|
10 | 11 |
|
@@ -1029,3 +1030,124 @@ type SemanticHighlightingToken struct {
|
1029 | 1030 | Length uint16
|
1030 | 1031 | Scope uint16
|
1031 | 1032 | }
|
| 1033 | + |
| 1034 | +type ProgressParams struct { |
| 1035 | + Token string `json:"token"` |
| 1036 | + Value interface{} `json:"value"` |
| 1037 | +} |
| 1038 | + |
| 1039 | +type WorkDoneProgressCreateParams struct { |
| 1040 | + Token string `json:"token"` |
| 1041 | +} |
| 1042 | + |
| 1043 | +type WorkDoneProgressCreateResult struct{} |
| 1044 | + |
| 1045 | +// MarshalJSON implements json.Marshaler. |
| 1046 | +func (v *WorkDoneProgressCreateResult) MarshalJSON() ([]byte, error) { |
| 1047 | + return []byte("null"), nil |
| 1048 | +} |
| 1049 | + |
| 1050 | +// UnmarshalJSON implements json.Unmarshaler. |
| 1051 | +func (v *WorkDoneProgressCreateResult) UnmarshalJSON(data []byte) error { |
| 1052 | + if bytes.Equal(data, []byte("null")) { |
| 1053 | + return nil |
| 1054 | + } |
| 1055 | + return errors.New("expected null") |
| 1056 | +} |
| 1057 | + |
| 1058 | +type WorkDoneProgressBegin struct { |
| 1059 | + Title string `json:"title"` |
| 1060 | + Cancellable *bool `json:"cancellable,omitempty"` |
| 1061 | + Message *string `json:"message,omitempty"` |
| 1062 | + Percentage *int `json:"percentage,omitempty"` |
| 1063 | +} |
| 1064 | + |
| 1065 | +// MarshalJSON implements json.Marshaler. |
| 1066 | +func (v WorkDoneProgressBegin) MarshalJSON() ([]byte, error) { |
| 1067 | + return json.Marshal(struct { |
| 1068 | + Title string `json:"title"` |
| 1069 | + Cancellable *bool `json:"cancellable,omitempty"` |
| 1070 | + Message *string `json:"message,omitempty"` |
| 1071 | + Percentage *int `json:"percentage,omitempty"` |
| 1072 | + Kind string `json:"kind"` |
| 1073 | + }{v.Title, v.Cancellable, v.Message, v.Percentage, "begin"}) |
| 1074 | +} |
| 1075 | + |
| 1076 | +// UnmarshalJSON implements json.Unmarshaler. |
| 1077 | +func (v *WorkDoneProgressBegin) UnmarshalJSON(data []byte) error { |
| 1078 | + type ProgressBegin struct { |
| 1079 | + WorkDoneProgressBegin |
| 1080 | + Kind string `json:"kind"` |
| 1081 | + } |
| 1082 | + var x ProgressBegin |
| 1083 | + if err := json.Unmarshal(data, &x); err != nil { |
| 1084 | + return err |
| 1085 | + } |
| 1086 | + if x.Kind != "begin" { |
| 1087 | + return errors.New(`expected kind == "begin"`) |
| 1088 | + } |
| 1089 | + *v = x.WorkDoneProgressBegin |
| 1090 | + return nil |
| 1091 | +} |
| 1092 | + |
| 1093 | +type WorkDoneProgressReport struct { |
| 1094 | + Cancellable *bool `json:"cancellable,omitempty"` |
| 1095 | + Message *string `json:"message,omitempty"` |
| 1096 | + Percentage *int `json:"percentage,omitempty"` |
| 1097 | +} |
| 1098 | + |
| 1099 | +// MarshalJSON implements json.Marshaler. |
| 1100 | +func (v WorkDoneProgressReport) MarshalJSON() ([]byte, error) { |
| 1101 | + return json.Marshal(struct { |
| 1102 | + Cancellable *bool `json:"cancellable,omitempty"` |
| 1103 | + Message *string `json:"message,omitempty"` |
| 1104 | + Percentage *int `json:"percentage,omitempty"` |
| 1105 | + Kind string `json:"kind"` |
| 1106 | + }{v.Cancellable, v.Message, v.Percentage, "report"}) |
| 1107 | +} |
| 1108 | + |
| 1109 | +// UnmarshalJSON implements json.Unmarshaler. |
| 1110 | +func (v *WorkDoneProgressReport) UnmarshalJSON(data []byte) error { |
| 1111 | + type ProgressReport struct { |
| 1112 | + WorkDoneProgressReport |
| 1113 | + Kind string `json:"kind"` |
| 1114 | + } |
| 1115 | + var x ProgressReport |
| 1116 | + if err := json.Unmarshal(data, &x); err != nil { |
| 1117 | + return err |
| 1118 | + } |
| 1119 | + if x.Kind != "report" { |
| 1120 | + return errors.New(`expected kind == "report"`) |
| 1121 | + } |
| 1122 | + *v = x.WorkDoneProgressReport |
| 1123 | + return nil |
| 1124 | +} |
| 1125 | + |
| 1126 | +type WorkDoneProgressEnd struct { |
| 1127 | + Message *string `json:"message,omitempty"` |
| 1128 | +} |
| 1129 | + |
| 1130 | +// MarshalJSON implements json.Marshaler. |
| 1131 | +func (v WorkDoneProgressEnd) MarshalJSON() ([]byte, error) { |
| 1132 | + return json.Marshal(struct { |
| 1133 | + Message *string `json:"message,omitempty"` |
| 1134 | + Kind string `json:"kind"` |
| 1135 | + }{v.Message, "end"}) |
| 1136 | +} |
| 1137 | + |
| 1138 | +// UnmarshalJSON implements json.Unmarshaler. |
| 1139 | +func (v *WorkDoneProgressEnd) UnmarshalJSON(data []byte) error { |
| 1140 | + type ProgressEnd struct { |
| 1141 | + WorkDoneProgressEnd |
| 1142 | + Kind string `json:"kind"` |
| 1143 | + } |
| 1144 | + var x ProgressEnd |
| 1145 | + if err := json.Unmarshal(data, &x); err != nil { |
| 1146 | + return err |
| 1147 | + } |
| 1148 | + if x.Kind != "end" { |
| 1149 | + return errors.New(`expected kind == "end"`) |
| 1150 | + } |
| 1151 | + *v = x.WorkDoneProgressEnd |
| 1152 | + return nil |
| 1153 | +} |
0 commit comments