@@ -40,7 +40,7 @@ type PackageJSON struct {
4040 Contributes struct {
4141 Commands []Command `json:"commands,omitempty"`
4242 Configuration struct {
43- Properties map [string ]Property `json:"properties,omitempty"`
43+ Properties map [string ]* Property `json:"properties,omitempty"`
4444 } `json:"configuration,omitempty"`
4545 } `json:"contributes,omitempty"`
4646}
@@ -55,16 +55,18 @@ type Property struct {
5555 name string `json:"name,omitempty"` // Set by us.
5656
5757 // 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"`
6870}
6971
7072type moduleVersion struct {
@@ -162,8 +164,8 @@ To update the settings, run "go run tools/generate.go -w".
162164 // Clear so that we can rewrite settings.md.
163165 b .Reset ()
164166
165- var properties []Property
166- var goplsProperty Property
167+ var properties []* Property
168+ var goplsProperty * Property
167169 for name , p := range pkgJSON .Contributes .Configuration .Properties {
168170 p .name = name
169171 if name == "gopls" {
@@ -277,7 +279,7 @@ func listAllModuleVersions(path string) (moduleVersion, error) {
277279 return version , nil
278280}
279281
280- func writeProperty (b * bytes.Buffer , heading string , p Property ) {
282+ func writeProperty (b * bytes.Buffer , heading string , p * Property ) {
281283 desc := p .Description
282284 if p .MarkdownDescription != "" {
283285 desc = p .MarkdownDescription
@@ -313,7 +315,7 @@ func writeProperty(b *bytes.Buffer, heading string, p Property) {
313315 }
314316}
315317
316- func defaultDescriptionSnippet (p Property ) string {
318+ func defaultDescriptionSnippet (p * Property ) string {
317319 if p .Default == nil {
318320 return ""
319321 }
@@ -367,7 +369,7 @@ func writeMapObject(b *bytes.Buffer, indent string, obj map[string]interface{})
367369 fmt .Fprintf (b , "%v}" , indent )
368370}
369371
370- func writeGoplsSettingsSection (b * bytes.Buffer , goplsProperty Property ) {
372+ func writeGoplsSettingsSection (b * bytes.Buffer , goplsProperty * Property ) {
371373 desc := goplsProperty .MarkdownDescription
372374 b .WriteString (desc )
373375 b .WriteString ("\n \n " )
@@ -380,58 +382,14 @@ func writeGoplsSettingsSection(b *bytes.Buffer, goplsProperty Property) {
380382 sort .Strings (names )
381383
382384 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
389387 writeProperty (b , "###" , p )
390388 b .WriteString ("\n " )
391389 }
392390}
393391
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 ) {
435393 if len (properties ) == 0 {
436394 return
437395 }
@@ -449,12 +407,8 @@ func writeSettingsObjectProperties(b *bytes.Buffer, properties map[string]interf
449407 if i == len (names )- 1 {
450408 ending = ""
451409 }
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
458412
459413 desc := p .Description
460414 if p .MarkdownDescription != "" {
@@ -487,7 +441,7 @@ func writeSettingsObjectProperties(b *bytes.Buffer, properties map[string]interf
487441}
488442
489443// enumDescriptionsSnippet returns the snippet for the allowed values.
490- func enumDescriptionsSnippet (p Property ) string {
444+ func enumDescriptionsSnippet (p * Property ) string {
491445 b := & bytes.Buffer {}
492446 if len (p .Enum ) == 0 {
493447 return ""
0 commit comments