@@ -40,7 +40,7 @@ type PackageJSON struct {
40
40
Contributes struct {
41
41
Commands []Command `json:"commands,omitempty"`
42
42
Configuration struct {
43
- Properties map [string ]Property `json:"properties,omitempty"`
43
+ Properties map [string ]* Property `json:"properties,omitempty"`
44
44
} `json:"configuration,omitempty"`
45
45
} `json:"contributes,omitempty"`
46
46
}
@@ -55,16 +55,18 @@ type Property struct {
55
55
name string `json:"name,omitempty"` // Set by us.
56
56
57
57
// Below are defined in package.json
58
- Properties map [string ]interface {} `json:"properties,omitempty"`
59
- Default interface {} `json:"default,omitempty"`
60
- MarkdownDescription string `json:"markdownDescription,omitempty"`
61
- Description string `json:"description,omitempty"`
62
- MarkdownDeprecationMessage string `json:"markdownDeprecationMessage,omitempty"`
63
- DeprecationMessage string `json:"deprecationMessage,omitempty"`
64
- Type interface {} `json:"type,omitempty"`
65
- Enum []interface {} `json:"enum,omitempty"`
66
- EnumDescriptions []string `json:"enumDescriptions,omitempty"`
67
- MarkdownEnumDescriptions []string `json:"markdownEnumDescriptions,omitempty"`
58
+ Properties map [string ]* Property `json:"properties,omitempty"`
59
+ AnyOf []Property `json:"anyOf,omitempty"`
60
+ Default interface {} `json:"default,omitempty"`
61
+ MarkdownDescription string `json:"markdownDescription,omitempty"`
62
+ Description string `json:"description,omitempty"`
63
+ MarkdownDeprecationMessage string `json:"markdownDeprecationMessage,omitempty"`
64
+ DeprecationMessage string `json:"deprecationMessage,omitempty"`
65
+ Type interface {} `json:"type,omitempty"`
66
+ Enum []interface {} `json:"enum,omitempty"`
67
+ EnumDescriptions []string `json:"enumDescriptions,omitempty"`
68
+ MarkdownEnumDescriptions []string `json:"markdownEnumDescriptions,omitempty"`
69
+ Items * Property `json:"items,omitempty"`
68
70
}
69
71
70
72
type moduleVersion struct {
@@ -162,8 +164,8 @@ To update the settings, run "go run tools/generate.go -w".
162
164
// Clear so that we can rewrite settings.md.
163
165
b .Reset ()
164
166
165
- var properties []Property
166
- var goplsProperty Property
167
+ var properties []* Property
168
+ var goplsProperty * Property
167
169
for name , p := range pkgJSON .Contributes .Configuration .Properties {
168
170
p .name = name
169
171
if name == "gopls" {
@@ -277,7 +279,7 @@ func listAllModuleVersions(path string) (moduleVersion, error) {
277
279
return version , nil
278
280
}
279
281
280
- func writeProperty (b * bytes.Buffer , heading string , p Property ) {
282
+ func writeProperty (b * bytes.Buffer , heading string , p * Property ) {
281
283
desc := p .Description
282
284
if p .MarkdownDescription != "" {
283
285
desc = p .MarkdownDescription
@@ -313,7 +315,7 @@ func writeProperty(b *bytes.Buffer, heading string, p Property) {
313
315
}
314
316
}
315
317
316
- func defaultDescriptionSnippet (p Property ) string {
318
+ func defaultDescriptionSnippet (p * Property ) string {
317
319
if p .Default == nil {
318
320
return ""
319
321
}
@@ -367,7 +369,7 @@ func writeMapObject(b *bytes.Buffer, indent string, obj map[string]interface{})
367
369
fmt .Fprintf (b , "%v}" , indent )
368
370
}
369
371
370
- func writeGoplsSettingsSection (b * bytes.Buffer , goplsProperty Property ) {
372
+ func writeGoplsSettingsSection (b * bytes.Buffer , goplsProperty * Property ) {
371
373
desc := goplsProperty .MarkdownDescription
372
374
b .WriteString (desc )
373
375
b .WriteString ("\n \n " )
@@ -380,58 +382,14 @@ func writeGoplsSettingsSection(b *bytes.Buffer, goplsProperty Property) {
380
382
sort .Strings (names )
381
383
382
384
for _ , name := range names {
383
- pdata , ok := properties [name ].(map [string ]interface {})
384
- if ! ok {
385
- fmt .Fprintf (b , "### `%s`\n " , name )
386
- continue
387
- }
388
- p := mapToProperty (name , pdata )
385
+ p := properties [name ]
386
+ p .name = name
389
387
writeProperty (b , "###" , p )
390
388
b .WriteString ("\n " )
391
389
}
392
390
}
393
391
394
- func mapToProperty (name string , pdata map [string ]interface {}) Property {
395
- p := Property {name : name }
396
-
397
- if v , ok := pdata ["properties" ].(map [string ]interface {}); ok {
398
- p .Properties = v
399
- }
400
- if v , ok := pdata ["markdownDescription" ].(string ); ok {
401
- p .MarkdownDescription = v
402
- }
403
- if v , ok := pdata ["description" ].(string ); ok {
404
- p .Description = v
405
- }
406
- if v , ok := pdata ["markdownDeprecationMessage" ].(string ); ok {
407
- p .MarkdownDescription = v
408
- }
409
- if v , ok := pdata ["deprecationMessage" ].(string ); ok {
410
- p .DeprecationMessage = v
411
- }
412
- if v , ok := pdata ["type" ].(string ); ok {
413
- p .Type = v
414
- }
415
- if v , ok := pdata ["enum" ].([]interface {}); ok {
416
- p .Enum = v
417
- }
418
- if v , ok := pdata ["enumDescriptions" ].([]interface {}); ok {
419
- for _ , d := range v {
420
- p .EnumDescriptions = append (p .EnumDescriptions , d .(string ))
421
- }
422
- }
423
- if v , ok := pdata ["markdownEnumDescriptions" ].([]interface {}); ok {
424
- for _ , d := range v {
425
- p .MarkdownEnumDescriptions = append (p .MarkdownEnumDescriptions , d .(string ))
426
- }
427
- }
428
- if v , ok := pdata ["default" ]; ok {
429
- p .Default = v
430
- }
431
- return p
432
- }
433
-
434
- func writeSettingsObjectProperties (b * bytes.Buffer , properties map [string ]interface {}) {
392
+ func writeSettingsObjectProperties (b * bytes.Buffer , properties map [string ]* Property ) {
435
393
if len (properties ) == 0 {
436
394
return
437
395
}
@@ -449,12 +407,8 @@ func writeSettingsObjectProperties(b *bytes.Buffer, properties map[string]interf
449
407
if i == len (names )- 1 {
450
408
ending = ""
451
409
}
452
- pdata , ok := properties [name ].(map [string ]interface {})
453
- if ! ok {
454
- fmt .Fprintf (b , "| `%s` | |%v" , name , ending )
455
- continue
456
- }
457
- p := mapToProperty (name , pdata )
410
+ p := properties [name ]
411
+ p .name = name
458
412
459
413
desc := p .Description
460
414
if p .MarkdownDescription != "" {
@@ -487,7 +441,7 @@ func writeSettingsObjectProperties(b *bytes.Buffer, properties map[string]interf
487
441
}
488
442
489
443
// enumDescriptionsSnippet returns the snippet for the allowed values.
490
- func enumDescriptionsSnippet (p Property ) string {
444
+ func enumDescriptionsSnippet (p * Property ) string {
491
445
b := & bytes.Buffer {}
492
446
if len (p .Enum ) == 0 {
493
447
return ""
0 commit comments