@@ -244,7 +244,45 @@ type TextDocumentSyncOptions struct {
244
244
Change TextDocumentSyncKind `json:"change"`
245
245
WillSave bool `json:"willSave,omitempty"`
246
246
WillSaveWaitUntil bool `json:"willSaveWaitUntil,omitempty"`
247
- Save * SaveOptions `json:"save,omitempty"`
247
+ Save * BoolOrSaveOptions `json:"save,omitempty"`
248
+ }
249
+
250
+ type BoolOrSaveOptions struct {
251
+ Save * bool
252
+ SaveOptions * SaveOptions
253
+ }
254
+
255
+ // MarshalJSON implements json.Marshaler.
256
+ func (v * BoolOrSaveOptions ) MarshalJSON () ([]byte , error ) {
257
+ if v .Save != nil {
258
+ return json .Marshal (v .Save )
259
+ }
260
+ if v .SaveOptions != nil {
261
+ return json .Marshal (v .SaveOptions )
262
+ }
263
+ return []byte ("null" ), nil
264
+ }
265
+
266
+ // UnmarshalJSON implements json.Unmarshaler.
267
+ func (v * BoolOrSaveOptions ) UnmarshalJSON (data []byte ) error {
268
+ if bytes .Equal (data , []byte ("null" )) {
269
+ v .Save = nil
270
+ v .SaveOptions = nil
271
+ return nil
272
+ }
273
+ var save bool
274
+ if err := json .Unmarshal (data , & save ); err == nil {
275
+ v .Save = & save
276
+ v .SaveOptions = nil
277
+ return nil
278
+ }
279
+ var saveOpts SaveOptions
280
+ if err := json .Unmarshal (data , & saveOpts ); err != nil {
281
+ return err
282
+ }
283
+ v .Save = nil
284
+ v .SaveOptions = & saveOpts
285
+ return nil
248
286
}
249
287
250
288
// TextDocumentSyncOptions holds either a TextDocumentSyncKind or
@@ -309,12 +347,12 @@ type ServerCapabilities struct {
309
347
DocumentSymbolProvider bool `json:"documentSymbolProvider,omitempty"`
310
348
WorkspaceSymbolProvider bool `json:"workspaceSymbolProvider,omitempty"`
311
349
ImplementationProvider bool `json:"implementationProvider,omitempty"`
312
- CodeActionProvider bool `json:"codeActionProvider,omitempty"`
350
+ CodeActionProvider * BoolOrCodeActionOptions `json:"codeActionProvider,omitempty"`
313
351
CodeLensProvider * CodeLensOptions `json:"codeLensProvider,omitempty"`
314
352
DocumentFormattingProvider bool `json:"documentFormattingProvider,omitempty"`
315
353
DocumentRangeFormattingProvider bool `json:"documentRangeFormattingProvider,omitempty"`
316
354
DocumentOnTypeFormattingProvider * DocumentOnTypeFormattingOptions `json:"documentOnTypeFormattingProvider,omitempty"`
317
- RenameProvider bool `json:"renameProvider,omitempty"`
355
+ RenameProvider * BoolOrRenameOptions `json:"renameProvider,omitempty"`
318
356
ExecuteCommandProvider * ExecuteCommandOptions `json:"executeCommandProvider,omitempty"`
319
357
SemanticHighlighting * SemanticHighlightingOptions `json:"semanticHighlighting,omitempty"`
320
358
@@ -352,6 +390,49 @@ type SignatureHelpOptions struct {
352
390
TriggerCharacters []string `json:"triggerCharacters,omitempty"`
353
391
}
354
392
393
+ type CodeActionOptions struct {
394
+ CodeActionKinds * []CodeActionKind `json:"codeActionKinds,omitempty`
395
+ ResolveProvider * bool `json:"resolveProvider,omitempty`
396
+ }
397
+
398
+ type BoolOrCodeActionOptions struct {
399
+ IsProvider * bool
400
+ Options * CodeActionOptions
401
+ }
402
+
403
+ // MarshalJSON implements json.Marshaler.
404
+ func (v * BoolOrCodeActionOptions ) MarshalJSON () ([]byte , error ) {
405
+ if v .IsProvider != nil {
406
+ return json .Marshal (v .IsProvider )
407
+ }
408
+ if v .Options != nil {
409
+ return json .Marshal (v .Options )
410
+ }
411
+ return []byte ("null" ), nil
412
+ }
413
+
414
+ // UnmarshalJSON implements json.Unmarshaler.
415
+ func (v * BoolOrCodeActionOptions ) UnmarshalJSON (data []byte ) error {
416
+ if bytes .Equal (data , []byte ("null" )) {
417
+ v .IsProvider = nil
418
+ v .Options = nil
419
+ return nil
420
+ }
421
+ var b bool
422
+ if err := json .Unmarshal (data , & b ); err == nil {
423
+ v .IsProvider = & b
424
+ v .Options = nil
425
+ return nil
426
+ }
427
+ var opts CodeActionOptions
428
+ if err := json .Unmarshal (data , & opts ); err != nil {
429
+ return err
430
+ }
431
+ v .IsProvider = nil
432
+ v .Options = & opts
433
+ return nil
434
+ }
435
+
355
436
type ExecuteCommandOptions struct {
356
437
Commands []string `json:"commands"`
357
438
}
@@ -361,6 +442,48 @@ type ExecuteCommandParams struct {
361
442
Arguments []interface {} `json:"arguments,omitempty"`
362
443
}
363
444
445
+ type RenameOptions struct {
446
+ PrepareProvider * bool `json:"prepareProvider,omitempty`
447
+ }
448
+
449
+ type BoolOrRenameOptions struct {
450
+ IsProvider * bool
451
+ Options * RenameOptions
452
+ }
453
+
454
+ // MarshalJSON implements json.Marshaler.
455
+ func (v * BoolOrRenameOptions ) MarshalJSON () ([]byte , error ) {
456
+ if v .IsProvider != nil {
457
+ return json .Marshal (v .IsProvider )
458
+ }
459
+ if v .Options != nil {
460
+ return json .Marshal (v .Options )
461
+ }
462
+ return []byte ("null" ), nil
463
+ }
464
+
465
+ // UnmarshalJSON implements json.Unmarshaler.
466
+ func (v * BoolOrRenameOptions ) UnmarshalJSON (data []byte ) error {
467
+ if bytes .Equal (data , []byte ("null" )) {
468
+ v .IsProvider = nil
469
+ v .Options = nil
470
+ return nil
471
+ }
472
+ var b bool
473
+ if err := json .Unmarshal (data , & b ); err == nil {
474
+ v .IsProvider = & b
475
+ v .Options = nil
476
+ return nil
477
+ }
478
+ var opts RenameOptions
479
+ if err := json .Unmarshal (data , & opts ); err != nil {
480
+ return err
481
+ }
482
+ v .IsProvider = nil
483
+ v .Options = & opts
484
+ return nil
485
+ }
486
+
364
487
type SemanticHighlightingOptions struct {
365
488
Scopes [][]string `json:"scopes,omitempty"`
366
489
}
0 commit comments