extension/tools/goplssetting: update copy of gopls json-api types

The types are moved to tools/gopls/internal/doc/api.go.

Remove `JSON` suffix from each name.

Change-Id: Ic5dae90f83f32f241a1e128aecd7def92aff34bc
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/616678
kokoro-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Commit-Queue: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/extension/tools/goplssetting/goplssetting.go b/extension/tools/goplssetting/goplssetting.go
index 8442ec8..6c13812 100644
--- a/extension/tools/goplssetting/goplssetting.go
+++ b/extension/tools/goplssetting/goplssetting.go
@@ -66,7 +66,7 @@
 }
 
 // readGoplsAPI returns the output of `gopls api-json`.
-func readGoplsAPI() (*APIJSON, error) {
+func readGoplsAPI() (*API, error) {
 	version, err := exec.Command("gopls", "-v", "version").Output()
 	if err != nil {
 		return nil, fmt.Errorf("failed to check gopls version: %v", err)
@@ -78,7 +78,7 @@
 		return nil, fmt.Errorf("failed to run gopls: %v", err)
 	}
 
-	api := &APIJSON{}
+	api := &API{}
 	if err := json.Unmarshal(out, api); err != nil {
 		return nil, fmt.Errorf("failed to unmarshal: %v", err)
 	}
@@ -87,37 +87,37 @@
 
 // extractOptions extracts the options from APIJSON.
 // It may rearrange the ordering and documentation for better presentation.
-func extractOptions(api *APIJSON) ([]*OptionJSON, error) {
+func extractOptions(api *API) ([]*Option, error) {
 	type sortableOptionJSON struct {
-		*OptionJSON
+		*Option
 		section string
 	}
 	options := []sortableOptionJSON{}
 	for k, v := range api.Options {
 		for _, o := range v {
-			options = append(options, sortableOptionJSON{OptionJSON: o, section: k})
+			options = append(options, sortableOptionJSON{Option: o, section: k})
 		}
 	}
 	sort.SliceStable(options, func(i, j int) bool {
-		pi := priority(options[i].OptionJSON)
-		pj := priority(options[j].OptionJSON)
+		pi := priority(options[i].Option)
+		pj := priority(options[j].Option)
 		if pi == pj {
 			return options[i].Name < options[j].Name
 		}
 		return pi < pj
 	})
 
-	opts := []*OptionJSON{}
+	opts := []*Option{}
 	for _, v := range options {
-		if name := statusName(v.OptionJSON); name != "" {
-			v.OptionJSON.Doc = name + " " + v.OptionJSON.Doc
+		if name := statusName(v.Option); name != "" {
+			v.Option.Doc = name + " " + v.Option.Doc
 		}
-		opts = append(opts, v.OptionJSON)
+		opts = append(opts, v.Option)
 	}
 	return opts, nil
 }
 
-func priority(opt *OptionJSON) int {
+func priority(opt *Option) int {
 	switch toStatus(opt.Status) {
 	case Experimental:
 		return 10
@@ -127,7 +127,7 @@
 	return 1000
 }
 
-func statusName(opt *OptionJSON) string {
+func statusName(opt *Option) string {
 	switch toStatus(opt.Status) {
 	case Experimental:
 		return "(Experimental)"
@@ -171,8 +171,8 @@
 
 // asVSCodeSettings converts the given options to match the VS Code settings
 // format.
-func asVSCodeSettings(options []*OptionJSON) ([]byte, error) {
-	seen := map[string][]*OptionJSON{}
+func asVSCodeSettings(options []*Option) ([]byte, error) {
+	seen := map[string][]*Option{}
 	for _, opt := range options {
 		seen[opt.Hierarchy] = append(seen[opt.Hierarchy], opt)
 	}
@@ -195,7 +195,7 @@
 	return json.Marshal(goProperties)
 }
 
-func collectProperties(m map[string][]*OptionJSON) (goplsProperties, goProperties map[string]*Object, err error) {
+func collectProperties(m map[string][]*Option) (goplsProperties, goProperties map[string]*Object, err error) {
 	var sorted []string
 	var containsEmpty bool
 	for k := range m {
@@ -248,7 +248,7 @@
 	return goplsProperties, goProperties, nil
 }
 
-func toObject(opt *OptionJSON) (*Object, error) {
+func toObject(opt *Option) (*Object, error) {
 	doc := opt.Doc
 	if mappedTo, ok := associatedToExtensionProperties[opt.Name]; ok {
 		doc = fmt.Sprintf("%v\nIf unspecified, values of `%v` will be propagated.\n", doc, strings.Join(mappedTo, ", "))
@@ -295,7 +295,7 @@
 	return obj, nil
 }
 
-func formatOptionDefault(opt *OptionJSON) interface{} {
+func formatOptionDefault(opt *Option) interface{} {
 	// Each key will have its own default value, instead of one large global
 	// one. (Alternatively, we can build the default from the keys.)
 	if len(opt.EnumKeys.Keys) > 0 {
@@ -388,18 +388,18 @@
 	None
 )
 
-// APIJSON is the output json type of `gopls api-json`.
-// Types copied from golang.org/x/tools/internal/lsp/source/options.go.
-type APIJSON struct {
-	Options   map[string][]*OptionJSON
-	Commands  []*CommandJSON
-	Lenses    []*LensJSON
-	Analyzers []*AnalyzerJSON
+// API is a JSON-encodable representation of gopls' public interfaces.
+//
+// Types are copied from golang.org/x/tools/gopls/internal/doc/api.go.
+type API struct {
+	Options   map[string][]*Option
+	Lenses    []*Lens
+	Analyzers []*Analyzer
 }
 
-type OptionJSON struct {
+type Option struct {
 	Name       string
-	Type       string
+	Type       string // T = bool | string | int | enum | any | []T | map[T]T | time.Duration
 	Doc        string
 	EnumKeys   EnumKeys
 	EnumValues []EnumValue
@@ -414,29 +414,32 @@
 }
 
 type EnumKey struct {
-	Name    string
+	Name    string // in JSON syntax (quoted)
 	Doc     string
 	Default string
 }
 
 type EnumValue struct {
-	Value string
-	Doc   string
+	Value string // in JSON syntax (quoted)
+	Doc   string // doc comment; always starts with `Value`
 }
 
-type CommandJSON struct {
-	Command string
-	Title   string
-	Doc     string
+type Lens struct {
+	FileType string // e.g. "Go", "go.mod"
+	Lens     string
+	Title    string
+	Doc      string
+	Default  bool
 }
 
-type LensJSON struct {
-	Lens  string
-	Title string
-	Doc   string
+type Analyzer struct {
+	Name    string
+	Doc     string // from analysis.Analyzer.Doc ("title: summary\ndescription"; not Markdown)
+	URL     string
+	Default bool
 }
 
-type AnalyzerJSON struct {
+type Hint struct {
 	Name    string
 	Doc     string
 	Default bool
diff --git a/extension/tools/goplssetting/goplssetting_test.go b/extension/tools/goplssetting/goplssetting_test.go
index 4a91241..0a35e4a 100644
--- a/extension/tools/goplssetting/goplssetting_test.go
+++ b/extension/tools/goplssetting/goplssetting_test.go
@@ -33,12 +33,12 @@
 	}
 	testCases := []struct {
 		name string
-		in   *OptionJSON
+		in   *Option
 		out  string
 	}{
 		{
 			name: "boolean",
-			in: &OptionJSON{
+			in: &Option{
 				Name:    "verboseOutput",
 				Type:    "bool",
 				Doc:     "verboseOutput enables additional debug logging.\n",
@@ -53,7 +53,7 @@
 		},
 		{
 			name: "time",
-			in: &OptionJSON{
+			in: &Option{
 				Name:    "completionBudget",
 				Type:    "time.Duration",
 				Default: "\"100ms\"",
@@ -66,7 +66,7 @@
 		},
 		{
 			name: "map",
-			in: &OptionJSON{
+			in: &Option{
 				Name:    "analyses",
 				Type:    "map[string]bool",
 				Default: "{}",
@@ -78,7 +78,7 @@
 		},
 		{
 			name: "enum",
-			in: &OptionJSON{
+			in: &Option{
 				Name: "matcher",
 				Type: "enum",
 				EnumValues: []EnumValue{
@@ -107,7 +107,7 @@
 		},
 		{
 			name: "array",
-			in: &OptionJSON{
+			in: &Option{
 				Name:    "directoryFilters",
 				Type:    "[]string",
 				Default: "[\"-node_modules\", \"-vendor\"]",
@@ -122,7 +122,7 @@
 
 	for _, tc := range testCases {
 		t.Run(tc.name, func(t *testing.T) {
-			options := []*OptionJSON{tc.in}
+			options := []*Option{tc.in}
 			b, err := asVSCodeSettings(options)
 			if err != nil {
 				t.Fatal(err)