Skip to content

Commit 8115161

Browse files
h9jianggopherbot
authored andcommitted
tools/goplssetting: read enum key and enum value status
VSCode-Go release tool can read gopls apijson's enum keys and enum values' status field (experimental, debug, advanced). The status will be added in the front of markdone description. x/tools CL 652356 Change-Id: I00333a9b63813369f1989e25131b8ce82827a022 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/652357 Reviewed-by: Alan Donovan <[email protected]> Auto-Submit: Hongxiang Jiang <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> kokoro-CI: kokoro <[email protected]>
1 parent 97c9ecd commit 8115161

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

extension/tools/goplssetting/goplssetting.go

+20-5
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,20 @@ func extractOptions(api *API) ([]*Option, error) {
111111

112112
opts := []*Option{}
113113
for _, v := range options {
114-
if name := statusName(v.Option); name != "" {
114+
if name := statusName(v.Option.Status); name != "" {
115115
v.Option.Doc = name + " " + v.Option.Doc
116116
}
117+
// Enum keys or values can be marked with status individually.
118+
for i, key := range v.EnumKeys.Keys {
119+
if name := statusName(key.Status); name != "" {
120+
v.EnumKeys.Keys[i].Doc = name + " " + key.Doc
121+
}
122+
}
123+
for i, value := range v.EnumValues {
124+
if name := statusName(value.Status); name != "" {
125+
v.EnumValues[i].Doc = name + " " + value.Doc
126+
}
127+
}
117128
opts = append(opts, v.Option)
118129
}
119130
return opts, nil
@@ -129,8 +140,8 @@ func priority(opt *Option) int {
129140
return 1000
130141
}
131142

132-
func statusName(opt *Option) string {
133-
switch toStatus(opt.Status) {
143+
func statusName(s string) string {
144+
switch toStatus(s) {
134145
case Experimental:
135146
return "(Experimental)"
136147
case Advanced:
@@ -453,11 +464,13 @@ type EnumKey struct {
453464
Name string // in JSON syntax (quoted)
454465
Doc string
455466
Default string
467+
Status string // = "" | "advanced" | "experimental" | "deprecated"
456468
}
457469

458470
type EnumValue struct {
459-
Value string // in JSON syntax (quoted)
460-
Doc string // doc comment; always starts with `Value`
471+
Value string // in JSON syntax (quoted)
472+
Doc string // doc comment; always starts with `Value`
473+
Status string // = "" | "advanced" | "experimental" | "deprecated"
461474
}
462475

463476
type Lens struct {
@@ -466,6 +479,7 @@ type Lens struct {
466479
Title string
467480
Doc string
468481
Default bool
482+
Status string // = "" | "advanced" | "experimental" | "deprecated"
469483
}
470484

471485
type Analyzer struct {
@@ -479,4 +493,5 @@ type Hint struct {
479493
Name string
480494
Doc string
481495
Default bool
496+
Status string // = "" | "advanced" | "experimental" | "deprecated"
482497
}

0 commit comments

Comments
 (0)