[tools] gopls/doc: use improved code generator for API doc

71 views
Skip to first unread message

Jonathan Amsterdam (Gerrit)

unread,
Dec 16, 2021, 6:15:39 AM12/16/21
to goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Gopher Robot, kokoro, Robert Findley, Heschi Kreinick, golang-co...@googlegroups.com

Jonathan Amsterdam submitted this change.

View Change



4 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:

```
The name of the file: gopls/go.sum
Insertions: 0, Deletions: 11.

@@ -1,7 +1,6 @@
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml v0.4.1 h1:GaI7EiDXDRfa8VshkTj7Fym7ha+y8/XxIgD2okUIjLw=
github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
-github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -10,12 +9,6 @@
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/safehtml v0.0.2 h1:ZOt2VXg4x24bW0m2jtzAOkhoXV0iM8vNKc0paByCZqM=
github.com/google/safehtml v0.0.2/go.mod h1:L4KWwDsUJdECRAEpZoBn3O64bQaywRscowZjJAzjHnU=
-github.com/jba/printsrc v0.1.1-0.20211213153036-18e6c07bfa0c h1:A0AGTPeGk9BxjWY4BC1xHjf1meeM/2miVEQcE6e/NUA=
-github.com/jba/printsrc v0.1.1-0.20211213153036-18e6c07bfa0c/go.mod h1:1xULjw59sL0dPdWpDoVU06TIEO/Wnfv6AHRpiElTwYM=
-github.com/jba/printsrc v0.2.0 h1:/fa53/df2aYm3GHNHYxnAU1fcFx0ENlKKY6CQVQBnp8=
-github.com/jba/printsrc v0.2.0/go.mod h1:1xULjw59sL0dPdWpDoVU06TIEO/Wnfv6AHRpiElTwYM=
-github.com/jba/printsrc v0.2.1 h1:Z3Nepget9NEm4CmDRyuPiGjDTDxJTe+v+Y/dh/qqMVs=
-github.com/jba/printsrc v0.2.1/go.mod h1:1xULjw59sL0dPdWpDoVU06TIEO/Wnfv6AHRpiElTwYM=
github.com/jba/printsrc v0.2.2 h1:9OHK51UT+/iMAEBlQIIXW04qvKyF3/vvLuwW/hL8tDU=
github.com/jba/printsrc v0.2.2/go.mod h1:1xULjw59sL0dPdWpDoVU06TIEO/Wnfv6AHRpiElTwYM=
github.com/jba/templatecheck v0.6.0 h1:SwM8C4hlK/YNLsdcXStfnHWE2HKkuTVwy5FKQHt5ro8=
@@ -24,17 +17,13 @@
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
-github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.6.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
-github.com/sanity-io/litter v1.5.1 h1:dwnrSypP6q56o3lFxTU+t2fwQ9A+U5qrXVO4Qg9KwVU=
-github.com/sanity-io/litter v1.5.1/go.mod h1:5Z71SvaYy5kcGtyglXOC9rrUi3c1E8CamFWjQsazTh0=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/testify v0.0.0-20161117074351-18a02ba4a312/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
```
```
The name of the file: gopls/go.mod
Insertions: 1, Deletions: 2.

@@ -4,8 +4,8 @@

require (
github.com/google/go-cmp v0.5.6
+ github.com/jba/printsrc v0.2.2
github.com/jba/templatecheck v0.6.0
- github.com/sanity-io/litter v1.5.1
github.com/sergi/go-diff v1.1.0
golang.org/x/mod v0.5.1
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654
@@ -18,7 +18,6 @@
require (
github.com/BurntSushi/toml v0.4.1 // indirect
github.com/google/safehtml v0.0.2 // indirect
- github.com/jba/printsrc v0.2.2 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
```

Approvals: Heschi Kreinick: Looks good to me, approved Robert Findley: Looks good to me, approved Jonathan Amsterdam: Trusted; Run TryBots Gopher Robot: TryBots succeeded kokoro: gopls CI succeeded
gopls/doc: use improved code generator for API doc

Use github.com/jba/printsrc in place of github.com/sanity-io/litter to
generate the Go code with API documentation. It is smart enough
to elide type names, making the "massive hack" of deleting them
unnecessary. It also omits zero values from the output.

Change-Id: Ic1bb937b9a3695e6da6db72b74c6049be1c5b80d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/370840
Trust: Jonathan Amsterdam <j...@google.com>
Run-TryBot: Jonathan Amsterdam <j...@google.com>
Reviewed-by: Heschi Kreinick <hes...@google.com>
Reviewed-by: Robert Findley <rfin...@google.com>
gopls-CI: kokoro <noreply...@google.com>
TryBot-Result: Gopher Robot <go...@golang.org>
---
M gopls/go.sum
M internal/lsp/source/api_json.go
M gopls/doc/generate.go
M gopls/doc/generate_test.go
M gopls/go.mod
5 files changed, 257 insertions(+), 464 deletions(-)

diff --git a/gopls/doc/generate.go b/gopls/doc/generate.go
index b6153e1..ee1424f 100644
--- a/gopls/doc/generate.go
+++ b/gopls/doc/generate.go
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

+//go:build go1.16
+// +build go1.16
+
// Command generate creates API (settings, etc) documentation in JSON and
// Markdown for machine and human consumption.
package main
@@ -26,7 +29,7 @@
"time"
"unicode"

- "github.com/sanity-io/litter"
+ "github.com/jba/printsrc"
"golang.org/x/tools/go/ast/astutil"
"golang.org/x/tools/go/packages"
"golang.org/x/tools/internal/lsp/command"
@@ -532,24 +535,12 @@
}

func rewriteAPI(_ []byte, api *source.APIJSON) ([]byte, error) {
- buf := bytes.NewBuffer(nil)
- apiStr := litter.Options{
- HomePackage: "source",
- }.Sdump(api)
- // Massive hack: filter out redundant types from the composite literal.
- apiStr = strings.ReplaceAll(apiStr, "&OptionJSON", "")
- apiStr = strings.ReplaceAll(apiStr, ": []*OptionJSON", ":")
- apiStr = strings.ReplaceAll(apiStr, "&CommandJSON", "")
- apiStr = strings.ReplaceAll(apiStr, "&LensJSON", "")
- apiStr = strings.ReplaceAll(apiStr, "&AnalyzerJSON", "")
- apiStr = strings.ReplaceAll(apiStr, " EnumValue{", "{")
- apiStr = strings.ReplaceAll(apiStr, " EnumKey{", "{")
- apiBytes, err := format.Source([]byte(apiStr))
- if err != nil {
+ var buf bytes.Buffer
+ fmt.Fprintf(&buf, "// Code generated by \"golang.org/x/tools/gopls/doc/generate\"; DO NOT EDIT.\n\npackage source\n\nvar GeneratedAPIJSON = ")
+ if err := printsrc.NewPrinter("golang.org/x/tools/internal/lsp/source").Fprint(&buf, api); err != nil {
return nil, err
}
- fmt.Fprintf(buf, "// Code generated by \"golang.org/x/tools/gopls/doc/generate\"; DO NOT EDIT.\n\npackage source\n\nvar GeneratedAPIJSON = %s\n", apiBytes)
- return buf.Bytes(), nil
+ return format.Source(buf.Bytes())
}

type optionsGroup struct {
diff --git a/gopls/doc/generate_test.go b/gopls/doc/generate_test.go
index 521d01c..137a646 100644
--- a/gopls/doc/generate_test.go
+++ b/gopls/doc/generate_test.go
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

+//go:build go1.16
+// +build go1.16
+
package main

import (
diff --git a/gopls/go.mod b/gopls/go.mod
index 9c08fbf..69efc0a 100644
--- a/gopls/go.mod
+++ b/gopls/go.mod
@@ -4,8 +4,8 @@

require (
github.com/google/go-cmp v0.5.6
+ github.com/jba/printsrc v0.2.2
github.com/jba/templatecheck v0.6.0
- github.com/sanity-io/litter v1.5.1
github.com/sergi/go-diff v1.1.0
golang.org/x/mod v0.5.1
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654
diff --git a/gopls/go.sum b/gopls/go.sum
index 147a497..b920420 100644
--- a/gopls/go.sum
+++ b/gopls/go.sum
@@ -1,7 +1,6 @@
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml v0.4.1 h1:GaI7EiDXDRfa8VshkTj7Fym7ha+y8/XxIgD2okUIjLw=
github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
-github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -10,23 +9,21 @@
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/safehtml v0.0.2 h1:ZOt2VXg4x24bW0m2jtzAOkhoXV0iM8vNKc0paByCZqM=
github.com/google/safehtml v0.0.2/go.mod h1:L4KWwDsUJdECRAEpZoBn3O64bQaywRscowZjJAzjHnU=
+github.com/jba/printsrc v0.2.2 h1:9OHK51UT+/iMAEBlQIIXW04qvKyF3/vvLuwW/hL8tDU=
+github.com/jba/printsrc v0.2.2/go.mod h1:1xULjw59sL0dPdWpDoVU06TIEO/Wnfv6AHRpiElTwYM=
github.com/jba/templatecheck v0.6.0 h1:SwM8C4hlK/YNLsdcXStfnHWE2HKkuTVwy5FKQHt5ro8=
github.com/jba/templatecheck v0.6.0/go.mod h1:/1k7EajoSErFI9GLHAsiIJEaNLt3ALKNw2TV7z2SYv4=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
-github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.6.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
-github.com/sanity-io/litter v1.5.1 h1:dwnrSypP6q56o3lFxTU+t2fwQ9A+U5qrXVO4Qg9KwVU=
-github.com/sanity-io/litter v1.5.1/go.mod h1:5Z71SvaYy5kcGtyglXOC9rrUi3c1E8CamFWjQsazTh0=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/testify v0.0.0-20161117074351-18a02ba4a312/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
diff --git a/internal/lsp/source/api_json.go b/internal/lsp/source/api_json.go
index 5c4e51d..95a1aff 100755
--- a/internal/lsp/source/api_json.go
+++ b/internal/lsp/source/api_json.go
@@ -6,333 +6,184 @@
Options: map[string][]*OptionJSON{
"User": {
{
- Name: "buildFlags",
- Type: "[]string",
- Doc: "buildFlags is the set of flags passed on to the build system when invoked.\nIt is applied to queries like `go list`, which is used when discovering files.\nThe most common use is to set `-tags`.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "[]",
- Status: "",
- Hierarchy: "build",
+ Name: "buildFlags",
+ Type: "[]string",
+ Doc: "buildFlags is the set of flags passed on to the build system when invoked.\nIt is applied to queries like `go list`, which is used when discovering files.\nThe most common use is to set `-tags`.\n",
+ Default: "[]",
+ Hierarchy: "build",
},
{
- Name: "env",
- Type: "map[string]string",
- Doc: "env adds environment variables to external commands run by `gopls`, most notably `go list`.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "{}",
- Status: "",
- Hierarchy: "build",
+ Name: "env",
+ Type: "map[string]string",
+ Doc: "env adds environment variables to external commands run by `gopls`, most notably `go list`.\n",
+ Default: "{}",
+ Hierarchy: "build",
},
{
- Name: "directoryFilters",
- Type: "[]string",
- Doc: "directoryFilters can be used to exclude unwanted directories from the\nworkspace. By default, all directories are included. Filters are an\noperator, `+` to include and `-` to exclude, followed by a path prefix\nrelative to the workspace folder. They are evaluated in order, and\nthe last filter that applies to a path controls whether it is included.\nThe path prefix can be empty, so an initial `-` excludes everything.\n\nExamples:\n\nExclude node_modules: `-node_modules`\n\nInclude only project_a: `-` (exclude everything), `+project_a`\n\nInclude only project_a, but not node_modules inside it: `-`, `+project_a`, `-project_a/node_modules`\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "[\"-node_modules\"]",
- Status: "",
- Hierarchy: "build",
+ Name: "directoryFilters",
+ Type: "[]string",
+ Doc: "directoryFilters can be used to exclude unwanted directories from the\nworkspace. By default, all directories are included. Filters are an\noperator, `+` to include and `-` to exclude, followed by a path prefix\nrelative to the workspace folder. They are evaluated in order, and\nthe last filter that applies to a path controls whether it is included.\nThe path prefix can be empty, so an initial `-` excludes everything.\n\nExamples:\n\nExclude node_modules: `-node_modules`\n\nInclude only project_a: `-` (exclude everything), `+project_a`\n\nInclude only project_a, but not node_modules inside it: `-`, `+project_a`, `-project_a/node_modules`\n",
+ Default: "[\"-node_modules\"]",
+ Hierarchy: "build",
},
{
- Name: "templateExtensions",
- Type: "[]string",
- Doc: "templateExtensions gives the extensions of file names that are treateed\nas template files. (The extension\nis the part of the file name after the final dot.)\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "[\"tmpl\",\"gotmpl\"]",
- Status: "",
- Hierarchy: "build",
+ Name: "templateExtensions",
+ Type: "[]string",
+ Doc: "templateExtensions gives the extensions of file names that are treateed\nas template files. (The extension\nis the part of the file name after the final dot.)\n",
+ Default: "[\"tmpl\",\"gotmpl\"]",
+ Hierarchy: "build",
},
{
Name: "memoryMode",
Type: "enum",
Doc: "memoryMode controls the tradeoff `gopls` makes between memory usage and\ncorrectness.\n\nValues other than `Normal` are untested and may break in surprising ways.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
EnumValues: []EnumValue{
{
Value: "\"DegradeClosed\"",
Doc: "`\"DegradeClosed\"`: In DegradeClosed mode, `gopls` will collect less information about\npackages without open files. As a result, features like Find\nReferences and Rename will miss results in such packages.\n",
},
- {
- Value: "\"Normal\"",
- Doc: "",
- },
+ {Value: "\"Normal\""},
},
Default: "\"Normal\"",
Status: "experimental",
Hierarchy: "build",
},
{
- Name: "expandWorkspaceToModule",
- Type: "bool",
- Doc: "expandWorkspaceToModule instructs `gopls` to adjust the scope of the\nworkspace to find the best available module root. `gopls` first looks for\na go.mod file in any parent directory of the workspace folder, expanding\nthe scope to that directory if it exists. If no viable parent directory is\nfound, gopls will check if there is exactly one child directory containing\na go.mod file, narrowing the scope to that directory if it exists.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "true",
- Status: "experimental",
- Hierarchy: "build",
+ Name: "expandWorkspaceToModule",
+ Type: "bool",
+ Doc: "expandWorkspaceToModule instructs `gopls` to adjust the scope of the\nworkspace to find the best available module root. `gopls` first looks for\na go.mod file in any parent directory of the workspace folder, expanding\nthe scope to that directory if it exists. If no viable parent directory is\nfound, gopls will check if there is exactly one child directory containing\na go.mod file, narrowing the scope to that directory if it exists.\n",
+ Default: "true",
+ Status: "experimental",
+ Hierarchy: "build",
},
{
- Name: "experimentalWorkspaceModule",
- Type: "bool",
- Doc: "experimentalWorkspaceModule opts a user into the experimental support\nfor multi-module workspaces.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "false",
- Status: "experimental",
- Hierarchy: "build",
+ Name: "experimentalWorkspaceModule",
+ Type: "bool",
+ Doc: "experimentalWorkspaceModule opts a user into the experimental support\nfor multi-module workspaces.\n",
+ Default: "false",
+ Status: "experimental",
+ Hierarchy: "build",
},
{
- Name: "experimentalPackageCacheKey",
- Type: "bool",
- Doc: "experimentalPackageCacheKey controls whether to use a coarser cache key\nfor package type information to increase cache hits. This setting removes\nthe user's environment, build flags, and working directory from the cache\nkey, which should be a safe change as all relevant inputs into the type\nchecking pass are already hashed into the key. This is temporarily guarded\nby an experiment because caching behavior is subtle and difficult to\ncomprehensively test.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "true",
- Status: "experimental",
- Hierarchy: "build",
+ Name: "experimentalPackageCacheKey",
+ Type: "bool",
+ Doc: "experimentalPackageCacheKey controls whether to use a coarser cache key\nfor package type information to increase cache hits. This setting removes\nthe user's environment, build flags, and working directory from the cache\nkey, which should be a safe change as all relevant inputs into the type\nchecking pass are already hashed into the key. This is temporarily guarded\nby an experiment because caching behavior is subtle and difficult to\ncomprehensively test.\n",
+ Default: "true",
+ Status: "experimental",
+ Hierarchy: "build",
},
{
- Name: "allowModfileModifications",
- Type: "bool",
- Doc: "allowModfileModifications disables -mod=readonly, allowing imports from\nout-of-scope modules. This option will eventually be removed.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "false",
- Status: "experimental",
- Hierarchy: "build",
+ Name: "allowModfileModifications",
+ Type: "bool",
+ Doc: "allowModfileModifications disables -mod=readonly, allowing imports from\nout-of-scope modules. This option will eventually be removed.\n",
+ Default: "false",
+ Status: "experimental",
+ Hierarchy: "build",
},
{
- Name: "allowImplicitNetworkAccess",
- Type: "bool",
- Doc: "allowImplicitNetworkAccess disables GOPROXY=off, allowing implicit module\ndownloads rather than requiring user action. This option will eventually\nbe removed.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "false",
- Status: "experimental",
- Hierarchy: "build",
+ Name: "allowImplicitNetworkAccess",
+ Type: "bool",
+ Doc: "allowImplicitNetworkAccess disables GOPROXY=off, allowing implicit module\ndownloads rather than requiring user action. This option will eventually\nbe removed.\n",
+ Default: "false",
+ Status: "experimental",
+ Hierarchy: "build",
},
{
- Name: "experimentalUseInvalidMetadata",
- Type: "bool",
- Doc: "experimentalUseInvalidMetadata enables gopls to fall back on outdated\npackage metadata to provide editor features if the go command fails to\nload packages for some reason (like an invalid go.mod file). This will\neventually be the default behavior, and this setting will be removed.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "false",
- Status: "experimental",
- Hierarchy: "build",
+ Name: "experimentalUseInvalidMetadata",
+ Type: "bool",
+ Doc: "experimentalUseInvalidMetadata enables gopls to fall back on outdated\npackage metadata to provide editor features if the go command fails to\nload packages for some reason (like an invalid go.mod file). This will\neventually be the default behavior, and this setting will be removed.\n",
+ Default: "false",
+ Status: "experimental",
+ Hierarchy: "build",
},
{
Name: "hoverKind",
Type: "enum",
Doc: "hoverKind controls the information that appears in the hover text.\nSingleLine and Structured are intended for use only by authors of editor plugins.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
EnumValues: []EnumValue{
- {
- Value: "\"FullDocumentation\"",
- Doc: "",
- },
- {
- Value: "\"NoDocumentation\"",
- Doc: "",
- },
- {
- Value: "\"SingleLine\"",
- Doc: "",
- },
+ {Value: "\"FullDocumentation\""},
+ {Value: "\"NoDocumentation\""},
+ {Value: "\"SingleLine\""},
{
Value: "\"Structured\"",
Doc: "`\"Structured\"` is an experimental setting that returns a structured hover format.\nThis format separates the signature from the documentation, so that the client\ncan do more manipulation of these fields.\n\nThis should only be used by clients that support this behavior.\n",
},
- {
- Value: "\"SynopsisDocumentation\"",
- Doc: "",
- },
+ {Value: "\"SynopsisDocumentation\""},
},
Default: "\"FullDocumentation\"",
- Status: "",
Hierarchy: "ui.documentation",
},
{
- Name: "linkTarget",
- Type: "string",
- Doc: "linkTarget controls where documentation links go.\nIt might be one of:\n\n* `\"godoc.org\"`\n* `\"pkg.go.dev\"`\n\nIf company chooses to use its own `godoc.org`, its address can be used as well.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "\"pkg.go.dev\"",
- Status: "",
- Hierarchy: "ui.documentation",
+ Name: "linkTarget",
+ Type: "string",
+ Doc: "linkTarget controls where documentation links go.\nIt might be one of:\n\n* `\"godoc.org\"`\n* `\"pkg.go.dev\"`\n\nIf company chooses to use its own `godoc.org`, its address can be used as well.\n",
+ Default: "\"pkg.go.dev\"",
+ Hierarchy: "ui.documentation",
},
{
- Name: "linksInHover",
- Type: "bool",
- Doc: "linksInHover toggles the presence of links to documentation in hover.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "true",
- Status: "",
- Hierarchy: "ui.documentation",
+ Name: "linksInHover",
+ Type: "bool",
+ Doc: "linksInHover toggles the presence of links to documentation in hover.\n",
+ Default: "true",
+ Hierarchy: "ui.documentation",
},
{
- Name: "usePlaceholders",
- Type: "bool",
- Doc: "placeholders enables placeholders for function parameters or struct\nfields in completion responses.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "false",
- Status: "",
- Hierarchy: "ui.completion",
+ Name: "usePlaceholders",
+ Type: "bool",
+ Doc: "placeholders enables placeholders for function parameters or struct\nfields in completion responses.\n",
+ Default: "false",
+ Hierarchy: "ui.completion",
},
{
- Name: "completionBudget",
- Type: "time.Duration",
- Doc: "completionBudget is the soft latency goal for completion requests. Most\nrequests finish in a couple milliseconds, but in some cases deep\ncompletions can take much longer. As we use up our budget we\ndynamically reduce the search scope to ensure we return timely\nresults. Zero means unlimited.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "\"100ms\"",
- Status: "debug",
- Hierarchy: "ui.completion",
+ Name: "completionBudget",
+ Type: "time.Duration",
+ Doc: "completionBudget is the soft latency goal for completion requests. Most\nrequests finish in a couple milliseconds, but in some cases deep\ncompletions can take much longer. As we use up our budget we\ndynamically reduce the search scope to ensure we return timely\nresults. Zero means unlimited.\n",
+ Default: "\"100ms\"",
+ Status: "debug",
+ Hierarchy: "ui.completion",
},
{
Name: "matcher",
Type: "enum",
Doc: "matcher sets the algorithm that is used when calculating completion\ncandidates.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
EnumValues: []EnumValue{
- {
- Value: "\"CaseInsensitive\"",
- Doc: "",
- },
- {
- Value: "\"CaseSensitive\"",
- Doc: "",
- },
- {
- Value: "\"Fuzzy\"",
- Doc: "",
- },
+ {Value: "\"CaseInsensitive\""},
+ {Value: "\"CaseSensitive\""},
+ {Value: "\"Fuzzy\""},
},
Default: "\"Fuzzy\"",
Status: "advanced",
Hierarchy: "ui.completion",
},
{
- Name: "experimentalPostfixCompletions",
- Type: "bool",
- Doc: "experimentalPostfixCompletions enables artifical method snippets\nsuch as \"someSlice.sort!\".\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "true",
- Status: "experimental",
- Hierarchy: "ui.completion",
+ Name: "experimentalPostfixCompletions",
+ Type: "bool",
+ Doc: "experimentalPostfixCompletions enables artifical method snippets\nsuch as \"someSlice.sort!\".\n",
+ Default: "true",
+ Status: "experimental",
+ Hierarchy: "ui.completion",
},
{
Name: "importShortcut",
Type: "enum",
Doc: "importShortcut specifies whether import statements should link to\ndocumentation or go to definitions.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
EnumValues: []EnumValue{
- {
- Value: "\"Both\"",
- Doc: "",
- },
- {
- Value: "\"Definition\"",
- Doc: "",
- },
- {
- Value: "\"Link\"",
- Doc: "",
- },
+ {Value: "\"Both\""},
+ {Value: "\"Definition\""},
+ {Value: "\"Link\""},
},
Default: "\"Both\"",
- Status: "",
Hierarchy: "ui.navigation",
},
{
Name: "symbolMatcher",
Type: "enum",
Doc: "symbolMatcher sets the algorithm that is used when finding workspace symbols.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
EnumValues: []EnumValue{
- {
- Value: "\"CaseInsensitive\"",
- Doc: "",
- },
- {
- Value: "\"CaseSensitive\"",
- Doc: "",
- },
- {
- Value: "\"FastFuzzy\"",
- Doc: "",
- },
- {
- Value: "\"Fuzzy\"",
- Doc: "",
- },
+ {Value: "\"CaseInsensitive\""},
+ {Value: "\"CaseSensitive\""},
+ {Value: "\"FastFuzzy\""},
+ {Value: "\"Fuzzy\""},
},
Default: "\"Fuzzy\"",
Status: "advanced",
@@ -342,10 +193,6 @@
Name: "symbolStyle",
Type: "enum",
Doc: "symbolStyle controls how symbols are qualified in symbol responses.\n\nExample Usage:\n\n```json5\n\"gopls\": {\n...\n \"symbolStyle\": \"Dynamic\",\n...\n}\n```\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
EnumValues: []EnumValue{
{
Value: "\"Dynamic\"",
@@ -588,23 +435,16 @@
},
},
},
- EnumValues: nil,
- Default: "{}",
- Status: "",
- Hierarchy: "ui.diagnostic",
+ Default: "{}",
+ Hierarchy: "ui.diagnostic",
},
{
- Name: "staticcheck",
- Type: "bool",
- Doc: "staticcheck enables additional analyses from staticcheck.io.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "false",
- Status: "experimental",
- Hierarchy: "ui.diagnostic",
+ Name: "staticcheck",
+ Type: "bool",
+ Doc: "staticcheck enables additional analyses from staticcheck.io.\n",
+ Default: "false",
+ Status: "experimental",
+ Hierarchy: "ui.diagnostic",
},
{
Name: "annotations",
@@ -635,36 +475,25 @@
},
},
},
- EnumValues: nil,
- Default: "{\"bounds\":true,\"escape\":true,\"inline\":true,\"nil\":true}",
- Status: "experimental",
- Hierarchy: "ui.diagnostic",
+ Default: "{\"bounds\":true,\"escape\":true,\"inline\":true,\"nil\":true}",
+ Status: "experimental",
+ Hierarchy: "ui.diagnostic",
},
{
- Name: "diagnosticsDelay",
- Type: "time.Duration",
- Doc: "diagnosticsDelay controls the amount of time that gopls waits\nafter the most recent file modification before computing deep diagnostics.\nSimple diagnostics (parsing and type-checking) are always run immediately\non recently modified packages.\n\nThis option must be set to a valid duration string, for example `\"250ms\"`.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "\"250ms\"",
- Status: "advanced",
- Hierarchy: "ui.diagnostic",
+ Name: "diagnosticsDelay",
+ Type: "time.Duration",
+ Doc: "diagnosticsDelay controls the amount of time that gopls waits\nafter the most recent file modification before computing deep diagnostics.\nSimple diagnostics (parsing and type-checking) are always run immediately\non recently modified packages.\n\nThis option must be set to a valid duration string, for example `\"250ms\"`.\n",
+ Default: "\"250ms\"",
+ Status: "advanced",
+ Hierarchy: "ui.diagnostic",
},
{
- Name: "experimentalWatchedFileDelay",
- Type: "time.Duration",
- Doc: "experimentalWatchedFileDelay controls the amount of time that gopls waits\nfor additional workspace/didChangeWatchedFiles notifications to arrive,\nbefore processing all such notifications in a single batch. This is\nintended for use by LSP clients that don't support their own batching of\nfile system notifications.\n\nThis option must be set to a valid duration string, for example `\"100ms\"`.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "\"0s\"",
- Status: "experimental",
- Hierarchy: "ui.diagnostic",
+ Name: "experimentalWatchedFileDelay",
+ Type: "time.Duration",
+ Doc: "experimentalWatchedFileDelay controls the amount of time that gopls waits\nfor additional workspace/didChangeWatchedFiles notifications to arrive,\nbefore processing all such notifications in a single batch. This is\nintended for use by LSP clients that don't support their own batching of\nfile system notifications.\n\nThis option must be set to a valid duration string, for example `\"100ms\"`.\n",
+ Default: "\"0s\"",
+ Status: "experimental",
+ Hierarchy: "ui.diagnostic",
},
{
Name: "codelenses",
@@ -710,121 +539,88 @@
},
},
},
- EnumValues: nil,
- Default: "{\"gc_details\":false,\"generate\":true,\"regenerate_cgo\":true,\"tidy\":true,\"upgrade_dependency\":true,\"vendor\":true}",
- Status: "",
- Hierarchy: "ui",
+ Default: "{\"gc_details\":false,\"generate\":true,\"regenerate_cgo\":true,\"tidy\":true,\"upgrade_dependency\":true,\"vendor\":true}",
+ Hierarchy: "ui",
},
{
- Name: "semanticTokens",
- Type: "bool",
- Doc: "semanticTokens controls whether the LSP server will send\nsemantic tokens to the client.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "false",
- Status: "experimental",
- Hierarchy: "ui",
+ Name: "semanticTokens",
+ Type: "bool",
+ Doc: "semanticTokens controls whether the LSP server will send\nsemantic tokens to the client.\n",
+ Default: "false",
+ Status: "experimental",
+ Hierarchy: "ui",
},
{
- Name: "local",
- Type: "string",
- Doc: "local is the equivalent of the `goimports -local` flag, which puts\nimports beginning with this string after third-party packages. It should\nbe the prefix of the import path whose imports should be grouped\nseparately.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "\"\"",
- Status: "",
- Hierarchy: "formatting",
+ Name: "local",
+ Type: "string",
+ Doc: "local is the equivalent of the `goimports -local` flag, which puts\nimports beginning with this string after third-party packages. It should\nbe the prefix of the import path whose imports should be grouped\nseparately.\n",
+ Default: "\"\"",
+ Hierarchy: "formatting",
},
{
- Name: "gofumpt",
- Type: "bool",
- Doc: "gofumpt indicates if we should run gofumpt formatting.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "false",
- Status: "",
- Hierarchy: "formatting",
+ Name: "gofumpt",
+ Type: "bool",
+ Doc: "gofumpt indicates if we should run gofumpt formatting.\n",
+ Default: "false",
+ Hierarchy: "formatting",
},
{
- Name: "verboseOutput",
- Type: "bool",
- Doc: "verboseOutput enables additional debug logging.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "false",
- Status: "debug",
- Hierarchy: "",
+ Name: "verboseOutput",
+ Type: "bool",
+ Doc: "verboseOutput enables additional debug logging.\n",
+ Default: "false",
+ Status: "debug",
},
},
},
Commands: []*CommandJSON{
{
- Command: "gopls.add_dependency",
- Title: "Add a dependency",
- Doc: "Adds a dependency to the go.mod file for a module.",
- ArgDoc: "{\n\t// The go.mod file URI.\n\t\"URI\": string,\n\t// Additional args to pass to the go command.\n\t\"GoCmdArgs\": []string,\n\t// Whether to add a require directive.\n\t\"AddRequire\": bool,\n}",
- ResultDoc: "",
+ Command: "gopls.add_dependency",
+ Title: "Add a dependency",
+ Doc: "Adds a dependency to the go.mod file for a module.",
+ ArgDoc: "{\n\t// The go.mod file URI.\n\t\"URI\": string,\n\t// Additional args to pass to the go command.\n\t\"GoCmdArgs\": []string,\n\t// Whether to add a require directive.\n\t\"AddRequire\": bool,\n}",
},
{
- Command: "gopls.add_import",
- Title: "Add an import",
- Doc: "Ask the server to add an import path to a given Go file. The method will\ncall applyEdit on the client so that clients don't have to apply the edit\nthemselves.",
- ArgDoc: "{\n\t// ImportPath is the target import path that should\n\t// be added to the URI file\n\t\"ImportPath\": string,\n\t// URI is the file that the ImportPath should be\n\t// added to\n\t\"URI\": string,\n}",
- ResultDoc: "",
+ Command: "gopls.add_import",
+ Title: "Add an import",
+ Doc: "Ask the server to add an import path to a given Go file. The method will\ncall applyEdit on the client so that clients don't have to apply the edit\nthemselves.",
+ ArgDoc: "{\n\t// ImportPath is the target import path that should\n\t// be added to the URI file\n\t\"ImportPath\": string,\n\t// URI is the file that the ImportPath should be\n\t// added to\n\t\"URI\": string,\n}",
},
{
- Command: "gopls.apply_fix",
- Title: "Apply a fix",
- Doc: "Applies a fix to a region of source code.",
- ArgDoc: "{\n\t// The fix to apply.\n\t\"Fix\": string,\n\t// The file URI for the document to fix.\n\t\"URI\": string,\n\t// The document range to scan for fixes.\n\t\"Range\": {\n\t\t\"start\": {\n\t\t\t\"line\": uint32,\n\t\t\t\"character\": uint32,\n\t\t},\n\t\t\"end\": {\n\t\t\t\"line\": uint32,\n\t\t\t\"character\": uint32,\n\t\t},\n\t},\n}",
- ResultDoc: "",
+ Command: "gopls.apply_fix",
+ Title: "Apply a fix",
+ Doc: "Applies a fix to a region of source code.",
+ ArgDoc: "{\n\t// The fix to apply.\n\t\"Fix\": string,\n\t// The file URI for the document to fix.\n\t\"URI\": string,\n\t// The document range to scan for fixes.\n\t\"Range\": {\n\t\t\"start\": {\n\t\t\t\"line\": uint32,\n\t\t\t\"character\": uint32,\n\t\t},\n\t\t\"end\": {\n\t\t\t\"line\": uint32,\n\t\t\t\"character\": uint32,\n\t\t},\n\t},\n}",
},
{
- Command: "gopls.check_upgrades",
- Title: "Check for upgrades",
- Doc: "Checks for module upgrades.",
- ArgDoc: "{\n\t// The go.mod file URI.\n\t\"URI\": string,\n\t// The modules to check.\n\t\"Modules\": []string,\n}",
- ResultDoc: "",
+ Command: "gopls.check_upgrades",
+ Title: "Check for upgrades",
+ Doc: "Checks for module upgrades.",
+ ArgDoc: "{\n\t// The go.mod file URI.\n\t\"URI\": string,\n\t// The modules to check.\n\t\"Modules\": []string,\n}",
},
{
- Command: "gopls.gc_details",
- Title: "Toggle gc_details",
- Doc: "Toggle the calculation of gc annotations.",
- ArgDoc: "string",
- ResultDoc: "",
+ Command: "gopls.gc_details",
+ Title: "Toggle gc_details",
+ Doc: "Toggle the calculation of gc annotations.",
+ ArgDoc: "string",
},
{
- Command: "gopls.generate",
- Title: "Run go generate",
- Doc: "Runs `go generate` for a given directory.",
- ArgDoc: "{\n\t// URI for the directory to generate.\n\t\"Dir\": string,\n\t// Whether to generate recursively (go generate ./...)\n\t\"Recursive\": bool,\n}",
- ResultDoc: "",
+ Command: "gopls.generate",
+ Title: "Run go generate",
+ Doc: "Runs `go generate` for a given directory.",
+ ArgDoc: "{\n\t// URI for the directory to generate.\n\t\"Dir\": string,\n\t// Whether to generate recursively (go generate ./...)\n\t\"Recursive\": bool,\n}",
},
{
- Command: "gopls.generate_gopls_mod",
- Title: "Generate gopls.mod",
- Doc: "(Re)generate the gopls.mod file for a workspace.",
- ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}",
- ResultDoc: "",
+ Command: "gopls.generate_gopls_mod",
+ Title: "Generate gopls.mod",
+ Doc: "(Re)generate the gopls.mod file for a workspace.",
+ ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}",
},
{
- Command: "gopls.go_get_package",
- Title: "go get a package",
- Doc: "Runs `go get` to fetch a package.",
- ArgDoc: "{\n\t// Any document URI within the relevant module.\n\t\"URI\": string,\n\t// The package to go get.\n\t\"Pkg\": string,\n\t\"AddRequire\": bool,\n}",
- ResultDoc: "",
+ Command: "gopls.go_get_package",
+ Title: "go get a package",
+ Doc: "Runs `go get` to fetch a package.",
+ ArgDoc: "{\n\t// Any document URI within the relevant module.\n\t\"URI\": string,\n\t// The package to go get.\n\t\"Pkg\": string,\n\t\"AddRequire\": bool,\n}",
},
{
Command: "gopls.list_known_packages",
@@ -834,25 +630,22 @@
ResultDoc: "{\n\t// Packages is a list of packages relative\n\t// to the URIArg passed by the command request.\n\t// In other words, it omits paths that are already\n\t// imported or cannot be imported due to compiler\n\t// restrictions.\n\t\"Packages\": []string,\n}",
},
{
- Command: "gopls.regenerate_cgo",
- Title: "Regenerate cgo",
- Doc: "Regenerates cgo definitions.",
- ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}",
- ResultDoc: "",
+ Command: "gopls.regenerate_cgo",
+ Title: "Regenerate cgo",
+ Doc: "Regenerates cgo definitions.",
+ ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}",
},
{
- Command: "gopls.remove_dependency",
- Title: "Remove a dependency",
- Doc: "Removes a dependency from the go.mod file of a module.",
- ArgDoc: "{\n\t// The go.mod file URI.\n\t\"URI\": string,\n\t// The module path to remove.\n\t\"ModulePath\": string,\n\t\"OnlyDiagnostic\": bool,\n}",
- ResultDoc: "",
+ Command: "gopls.remove_dependency",
+ Title: "Remove a dependency",
+ Doc: "Removes a dependency from the go.mod file of a module.",
+ ArgDoc: "{\n\t// The go.mod file URI.\n\t\"URI\": string,\n\t// The module path to remove.\n\t\"ModulePath\": string,\n\t\"OnlyDiagnostic\": bool,\n}",
},
{
- Command: "gopls.run_tests",
- Title: "Run test(s)",
- Doc: "Runs `go test` for a specific set of test or benchmark functions.",
- ArgDoc: "{\n\t// The test file containing the tests to run.\n\t\"URI\": string,\n\t// Specific test names to run, e.g. TestFoo.\n\t\"Tests\": []string,\n\t// Specific benchmarks to run, e.g. BenchmarkFoo.\n\t\"Benchmarks\": []string,\n}",
- ResultDoc: "",
+ Command: "gopls.run_tests",
+ Title: "Run test(s)",
+ Doc: "Runs `go test` for a specific set of test or benchmark functions.",
+ ArgDoc: "{\n\t// The test file containing the tests to run.\n\t\"URI\": string,\n\t// Specific test names to run, e.g. TestFoo.\n\t\"Tests\": []string,\n\t// Specific benchmarks to run, e.g. BenchmarkFoo.\n\t\"Benchmarks\": []string,\n}",
},
{
Command: "gopls.start_debugging",
@@ -862,52 +655,45 @@
ResultDoc: "{\n\t// The URLs to use to access the debug servers, for all gopls instances in\n\t// the serving path. For the common case of a single gopls instance (i.e. no\n\t// daemon), this will be exactly one address.\n\t// \n\t// In the case of one or more gopls instances forwarding the LSP to a daemon,\n\t// URLs will contain debug addresses for each server in the serving path, in\n\t// serving order. The daemon debug address will be the last entry in the\n\t// slice. If any intermediate gopls instance fails to start debugging, no\n\t// error will be returned but the debug URL for that server in the URLs slice\n\t// will be empty.\n\t\"URLs\": []string,\n}",
},
{
- Command: "gopls.test",
- Title: "Run test(s) (legacy)",
- Doc: "Runs `go test` for a specific set of test or benchmark functions.",
- ArgDoc: "string,\n[]string,\n[]string",
- ResultDoc: "",
+ Command: "gopls.test",
+ Title: "Run test(s) (legacy)",
+ Doc: "Runs `go test` for a specific set of test or benchmark functions.",
+ ArgDoc: "string,\n[]string,\n[]string",
},
{
- Command: "gopls.tidy",
- Title: "Run go mod tidy",
- Doc: "Runs `go mod tidy` for a module.",
- ArgDoc: "{\n\t// The file URIs.\n\t\"URIs\": []string,\n}",
- ResultDoc: "",
+ Command: "gopls.tidy",
+ Title: "Run go mod tidy",
+ Doc: "Runs `go mod tidy` for a module.",
+ ArgDoc: "{\n\t// The file URIs.\n\t\"URIs\": []string,\n}",
},
{
- Command: "gopls.toggle_gc_details",
- Title: "Toggle gc_details",
- Doc: "Toggle the calculation of gc annotations.",
- ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}",
- ResultDoc: "",
+ Command: "gopls.toggle_gc_details",
+ Title: "Toggle gc_details",
+ Doc: "Toggle the calculation of gc annotations.",
+ ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}",
},
{
- Command: "gopls.update_go_sum",
- Title: "Update go.sum",
- Doc: "Updates the go.sum file for a module.",
- ArgDoc: "{\n\t// The file URIs.\n\t\"URIs\": []string,\n}",
- ResultDoc: "",
+ Command: "gopls.update_go_sum",
+ Title: "Update go.sum",
+ Doc: "Updates the go.sum file for a module.",
+ ArgDoc: "{\n\t// The file URIs.\n\t\"URIs\": []string,\n}",
},
{
- Command: "gopls.upgrade_dependency",
- Title: "Upgrade a dependency",
- Doc: "Upgrades a dependency in the go.mod file for a module.",
- ArgDoc: "{\n\t// The go.mod file URI.\n\t\"URI\": string,\n\t// Additional args to pass to the go command.\n\t\"GoCmdArgs\": []string,\n\t// Whether to add a require directive.\n\t\"AddRequire\": bool,\n}",
- ResultDoc: "",
+ Command: "gopls.upgrade_dependency",
+ Title: "Upgrade a dependency",
+ Doc: "Upgrades a dependency in the go.mod file for a module.",
+ ArgDoc: "{\n\t// The go.mod file URI.\n\t\"URI\": string,\n\t// Additional args to pass to the go command.\n\t\"GoCmdArgs\": []string,\n\t// Whether to add a require directive.\n\t\"AddRequire\": bool,\n}",
},
{
- Command: "gopls.vendor",
- Title: "Run go mod vendor",
- Doc: "Runs `go mod vendor` for a module.",
- ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}",
- ResultDoc: "",
+ Command: "gopls.vendor",
+ Title: "Run go mod vendor",
+ Doc: "Runs `go mod vendor` for a module.",
+ ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}",
},
{
Command: "gopls.workspace_metadata",
Title: "Query workspace metadata",
Doc: "Query the server for information about active workspaces.",
- ArgDoc: "",
ResultDoc: "{\n\t// All workspaces for this session.\n\t\"Workspaces\": []{\n\t\t\"Name\": string,\n\t\t\"ModuleDir\": string,\n\t},\n}",
},
},
@@ -1005,9 +791,8 @@
Default: true,
},
{
- Name: "fieldalignment",
- Doc: "find structs that would use less memory if their fields were sorted\n\nThis analyzer find structs that can be rearranged to use less memory, and provides\na suggested edit with the optimal order.\n\nNote that there are two different diagnostics reported. One checks struct size,\nand the other reports \"pointer bytes\" used. Pointer bytes is how many bytes of the\nobject that the garbage collector has to potentially scan for pointers, for example:\n\n\tstruct { uint32; string }\n\nhave 16 pointer bytes because the garbage collector has to scan up through the string's\ninner pointer.\n\n\tstruct { string; *uint32 }\n\nhas 24 pointer bytes because it has to scan further through the *uint32.\n\n\tstruct { string; uint32 }\n\nhas 8 because it can stop immediately after the string pointer.\n",
- Default: false,
+ Name: "fieldalignment",
+ Doc: "find structs that would use less memory if their fields were sorted\n\nThis analyzer find structs that can be rearranged to use less memory, and provides\na suggested edit with the optimal order.\n\nNote that there are two different diagnostics reported. One checks struct size,\nand the other reports \"pointer bytes\" used. Pointer bytes is how many bytes of the\nobject that the garbage collector has to potentially scan for pointers, for example:\n\n\tstruct { uint32; string }\n\nhave 16 pointer bytes because the garbage collector has to scan up through the string's\ninner pointer.\n\n\tstruct { string; *uint32 }\n\nhas 24 pointer bytes because it has to scan further through the *uint32.\n\n\tstruct { string; uint32 }\n\nhas 8 because it can stop immediately after the string pointer.\n",
},
{
Name: "httpresponse",
@@ -1040,9 +825,8 @@
Default: true,
},
{
- Name: "nilness",
- Doc: "check for redundant or impossible nil comparisons\n\nThe nilness checker inspects the control-flow graph of each function in\na package and reports nil pointer dereferences, degenerate nil\npointers, and panics with nil values. A degenerate comparison is of the form\nx==nil or x!=nil where x is statically known to be nil or non-nil. These are\noften a mistake, especially in control flow related to errors. Panics with nil\nvalues are checked because they are not detectable by\n\n\tif r := recover(); r != nil {\n\nThis check reports conditions such as:\n\n\tif f == nil { // impossible condition (f is a function)\n\t}\n\nand:\n\n\tp := &v\n\t...\n\tif p != nil { // tautological condition\n\t}\n\nand:\n\n\tif p == nil {\n\t\tprint(*p) // nil dereference\n\t}\n\nand:\n\n\tif p == nil {\n\t\tpanic(p)\n\t}\n",
- Default: false,
+ Name: "nilness",
+ Doc: "check for redundant or impossible nil comparisons\n\nThe nilness checker inspects the control-flow graph of each function in\na package and reports nil pointer dereferences, degenerate nil\npointers, and panics with nil values. A degenerate comparison is of the form\nx==nil or x!=nil where x is statically known to be nil or non-nil. These are\noften a mistake, especially in control flow related to errors. Panics with nil\nvalues are checked because they are not detectable by\n\n\tif r := recover(); r != nil {\n\nThis check reports conditions such as:\n\n\tif f == nil { // impossible condition (f is a function)\n\t}\n\nand:\n\n\tp := &v\n\t...\n\tif p != nil { // tautological condition\n\t}\n\nand:\n\n\tif p == nil {\n\t\tprint(*p) // nil dereference\n\t}\n\nand:\n\n\tif p == nil {\n\t\tpanic(p)\n\t}\n",
},
{
Name: "printf",
@@ -1050,9 +834,8 @@
Default: true,
},
{
- Name: "shadow",
- Doc: "check for possible unintended shadowing of variables\n\nThis analyzer check for shadowed variables.\nA shadowed variable is a variable declared in an inner scope\nwith the same name and type as a variable in an outer scope,\nand where the outer variable is mentioned after the inner one\nis declared.\n\n(This definition can be refined; the module generates too many\nfalse positives and is not yet enabled by default.)\n\nFor example:\n\n\tfunc BadRead(f *os.File, buf []byte) error {\n\t\tvar err error\n\t\tfor {\n\t\t\tn, err := f.Read(buf) // shadows the function variable 'err'\n\t\t\tif err != nil {\n\t\t\t\tbreak // causes return of wrong value\n\t\t\t}\n\t\t\tfoo(buf)\n\t\t}\n\t\treturn err\n\t}\n",
- Default: false,
+ Name: "shadow",
+ Doc: "check for possible unintended shadowing of variables\n\nThis analyzer check for shadowed variables.\nA shadowed variable is a variable declared in an inner scope\nwith the same name and type as a variable in an outer scope,\nand where the outer variable is mentioned after the inner one\nis declared.\n\n(This definition can be refined; the module generates too many\nfalse positives and is not yet enabled by default.)\n\nFor example:\n\n\tfunc BadRead(f *os.File, buf []byte) error {\n\t\tvar err error\n\t\tfor {\n\t\t\tn, err := f.Read(buf) // shadows the function variable 'err'\n\t\t\tif err != nil {\n\t\t\t\tbreak // causes return of wrong value\n\t\t\t}\n\t\t\tfoo(buf)\n\t\t}\n\t\treturn err\n\t}\n",
},
{
Name: "shift",
@@ -1120,9 +903,8 @@
Default: true,
},
{
- Name: "unusedparams",
- Doc: "check for unused parameters of functions\n\nThe unusedparams analyzer checks functions to see if there are\nany parameters that are not being used.\n\nTo reduce false positives it ignores:\n- methods\n- parameters that do not have a name or are underscored\n- functions in test files\n- functions with empty bodies or those with just a return stmt",
- Default: false,
+ Name: "unusedparams",
+ Doc: "check for unused parameters of functions\n\nThe unusedparams analyzer checks functions to see if there are\nany parameters that are not being used.\n\nTo reduce false positives it ignores:\n- methods\n- parameters that do not have a name or are underscored\n- functions in test files\n- functions with empty bodies or those with just a return stmt",
},
{
Name: "unusedresult",
@@ -1130,9 +912,8 @@
Default: true,
},
{
- Name: "unusedwrite",
- Doc: "checks for unused writes\n\nThe analyzer reports instances of writes to struct fields and\narrays that are never read. Specifically, when a struct object\nor an array is copied, its elements are copied implicitly by\nthe compiler, and any element write to this copy does nothing\nwith the original object.\n\nFor example:\n\n\ttype T struct { x int }\n\tfunc f(input []T) {\n\t\tfor i, v := range input { // v is a copy\n\t\t\tv.x = i // unused write to field x\n\t\t}\n\t}\n\nAnother example is about non-pointer receiver:\n\n\ttype T struct { x int }\n\tfunc (t T) f() { // t is a copy\n\t\tt.x = i // unused write to field x\n\t}\n",
- Default: false,
+ Name: "unusedwrite",
+ Doc: "checks for unused writes\n\nThe analyzer reports instances of writes to struct fields and\narrays that are never read. Specifically, when a struct object\nor an array is copied, its elements are copied implicitly by\nthe compiler, and any element write to this copy does nothing\nwith the original object.\n\nFor example:\n\n\ttype T struct { x int }\n\tfunc f(input []T) {\n\t\tfor i, v := range input { // v is a copy\n\t\t\tv.x = i // unused write to field x\n\t\t}\n\t}\n\nAnother example is about non-pointer receiver:\n\n\ttype T struct { x int }\n\tfunc (t T) f() { // t is a copy\n\t\tt.x = i // unused write to field x\n\t}\n",
},
{
Name: "useany",

To view, visit change 370840. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: Ic1bb937b9a3695e6da6db72b74c6049be1c5b80d
Gerrit-Change-Number: 370840
Gerrit-PatchSet: 6
Gerrit-Owner: Jonathan Amsterdam <j...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Heschi Kreinick <hes...@google.com>
Gerrit-Reviewer: Jonathan Amsterdam <j...@google.com>
Gerrit-Reviewer: Robert Findley <rfin...@google.com>
Gerrit-Reviewer: kokoro <noreply...@google.com>
Gerrit-MessageType: merged
Reply all
Reply to author
Forward
0 new messages