diff --git a/MODULE.bazel b/MODULE.bazel index 34e72c7f3..27c1b6064 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,6 +1,6 @@ module( name = "rules_go", - version = "0.47.1", + version = "0.48.0", compatibility_level = 0, repo_name = "io_bazel_rules_go", ) diff --git a/go/def.bzl b/go/def.bzl index 9def94efe..e51da6f2a 100644 --- a/go/def.bzl +++ b/go/def.bzl @@ -121,7 +121,7 @@ TOOLS_NOGO = [str(Label(l)) for l in _TOOLS_NOGO] # Current version or next version to be tagged. Gazelle and other tools may # check this to determine compatibility. -RULES_GO_VERSION = "0.47.1" +RULES_GO_VERSION = "0.48.0" go_context = _go_context gomock = _gomock diff --git a/go/private/repositories.bzl b/go/private/repositories.bzl index 934bf517d..bd9121d81 100644 --- a/go/private/repositories.bzl +++ b/go/private/repositories.bzl @@ -51,12 +51,12 @@ def go_rules_dependencies(force = False): wrapper( http_archive, name = "bazel_skylib", - # 1.5.0, latest as of 2024-04-19 + # 1.6.1, latest as of 2024-05-20 urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz", - "https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.6.1/bazel-skylib-1.6.1.tar.gz", + "https://github.com/bazelbuild/bazel-skylib/releases/download/1.6.1/bazel-skylib-1.6.1.tar.gz", ], - sha256 = "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94", + sha256 = "9f38886a40548c6e96c106b752f242130ee11aaa068a56ba7e56f4511f33e4f2", strip_prefix = "", ) @@ -65,13 +65,13 @@ def go_rules_dependencies(force = False): wrapper( http_archive, name = "org_golang_x_tools", - # v0.20.0, latest as of 2024-04-19 + # v0.21.0, latest as of 2024-05-20 urls = [ - "https://mirror.bazel.build/github.com/golang/tools/archive/refs/tags/v0.20.0.zip", - "https://github.com/golang/tools/archive/refs/tags/v0.20.0.zip", + "https://mirror.bazel.build/github.com/golang/tools/archive/refs/tags/v0.21.0.zip", + "https://github.com/golang/tools/archive/refs/tags/v0.21.0.zip", ], - sha256 = "06d29c1c1844c668bad5d57c755f5a11b99242f7a8ecd09c7b5f66aabeab32bc", - strip_prefix = "tools-0.20.0", + sha256 = "3e679aad1044575b90c14d13f2caa27840e46b38ac2a1dd391937300af56467a", + strip_prefix = "tools-0.21.0", patches = [ # deletegopls removes the gopls subdirectory. It contains a nested # module with additional dependencies. It's not needed by rules_go. @@ -106,13 +106,13 @@ def go_rules_dependencies(force = False): wrapper( http_archive, name = "org_golang_x_sys", - # v0.19.0, latest as of 2024-04-19 + # v0.20.0, latest as of 2024-05-20 urls = [ - "https://mirror.bazel.build/github.com/golang/sys/archive/refs/tags/v0.19.0.zip", - "https://github.com/golang/sys/archive/refs/tags/v0.19.0.zip", + "https://mirror.bazel.build/github.com/golang/sys/archive/refs/tags/v0.20.0.zip", + "https://github.com/golang/sys/archive/refs/tags/v0.20.0.zip", ], - sha256 = "a2fa1126030bf928b0ab559d2e985ea99fc974bf58a2d512f4e2e1a5303a57ae", - strip_prefix = "sys-0.19.0", + sha256 = "e9ad578952169036fb5023b0f53c0315d5f73146fc33d70255fa6d6edd859f84", + strip_prefix = "sys-0.20.0", patches = [ # releaser:patch-cmd gazelle -repo_root . -go_prefix golang.org/x/sys -go_naming_convention import_alias Label("//third_party:org_golang_x_sys-gazelle.patch"), @@ -125,7 +125,7 @@ def go_rules_dependencies(force = False): wrapper( http_archive, name = "org_golang_x_xerrors", - # master, as of 2024-04-19 + # master, as of 2024-05-20 urls = [ "https://mirror.bazel.build/github.com/golang/xerrors/archive/104605ab7028f4af38a8aff92ac848a51bd53c5d.zip", "https://github.com/golang/xerrors/archive/104605ab7028f4af38a8aff92ac848a51bd53c5d.zip", @@ -180,7 +180,7 @@ def go_rules_dependencies(force = False): http_archive, name = "org_golang_google_grpc_cmd_protoc_gen_go_grpc", sha256 = "1e84df03c94d1cded8e94da7a2df162463f3be4c7a94289d85c0871f14c7b8e3", - # cmd/protoc-gen-go-grpc/v1.3.0, latest as of 2024-04-19 + # cmd/protoc-gen-go-grpc/v1.3.0, latest as of 2024-05-20 urls = [ "https://mirror.bazel.build/github.com/grpc/grpc-go/archive/refs/tags/cmd/protoc-gen-go-grpc/v1.3.0.zip", "https://github.com/grpc/grpc-go/archive/refs/tags/cmd/protoc-gen-go-grpc/v1.3.0.zip", @@ -200,7 +200,7 @@ def go_rules_dependencies(force = False): wrapper( http_archive, name = "com_github_golang_protobuf", - # v1.5.4, latest as of 2024-04-19 + # v1.5.4, latest as of 2024-05-20 urls = [ "https://mirror.bazel.build/github.com/golang/protobuf/archive/refs/tags/v1.5.4.zip", "https://github.com/golang/protobuf/archive/refs/tags/v1.5.4.zip", @@ -218,7 +218,7 @@ def go_rules_dependencies(force = False): wrapper( http_archive, name = "com_github_gogo_protobuf", - # v1.3.2, latest as of 2024-04-19 + # v1.3.2, latest as of 2024-05-20 urls = [ "https://mirror.bazel.build/github.com/gogo/protobuf/archive/refs/tags/v1.3.2.zip", "https://github.com/gogo/protobuf/archive/refs/tags/v1.3.2.zip", @@ -244,13 +244,13 @@ def go_rules_dependencies(force = False): wrapper( http_archive, name = "org_golang_google_genproto", - # main, as of 2024-04-19 + # main, as of 2024-05-20 urls = [ - "https://mirror.bazel.build/github.com/googleapis/go-genproto/archive/8c6c420018be7d99c6336d84554d856523d514bf.zip", - "https://github.com/googleapis/go-genproto/archive/8c6c420018be7d99c6336d84554d856523d514bf.zip", + "https://mirror.bazel.build/github.com/googleapis/go-genproto/archive/dc85e6b867a5ebdfeaa293ddb423f00255ec921e.zip", + "https://github.com/googleapis/go-genproto/archive/dc85e6b867a5ebdfeaa293ddb423f00255ec921e.zip", ], - sha256 = "eddb238f5a61df730989baa6e0303666af3adf2835f226185e6c64f2958855c9", - strip_prefix = "go-genproto-8c6c420018be7d99c6336d84554d856523d514bf", + sha256 = "ef3c82a1e6951a7931107d00ad4fe034366903290feae82bb1a19211c86d9d2f", + strip_prefix = "go-genproto-dc85e6b867a5ebdfeaa293ddb423f00255ec921e", patches = [ # releaser:patch-cmd gazelle -repo_root . -go_prefix google.golang.org/genproto -go_naming_convention import_alias -proto disable_global Label("//third_party:org_golang_google_genproto-gazelle.patch"), @@ -262,7 +262,7 @@ def go_rules_dependencies(force = False): _maybe( http_archive, name = "com_github_golang_mock", - # v1.6.0, latest as of 2024-04-19 + # v1.6.0, latest as of 2024-05-20 urls = [ "https://mirror.bazel.build/github.com/golang/mock/archive/refs/tags/v1.6.0.zip", "https://github.com/golang/mock/archive/refs/tags/v1.6.0.zip", diff --git a/third_party/org_golang_google_genproto-gazelle.patch b/third_party/org_golang_google_genproto-gazelle.patch index c857bbc63..6f2e2d535 100644 --- a/third_party/org_golang_google_genproto-gazelle.patch +++ b/third_party/org_golang_google_genproto-gazelle.patch @@ -9135,7 +9135,7 @@ diff -urN a/googleapis/datastore/admin/v1beta1/BUILD.bazel b/googleapis/datastor + visibility = ["//visibility:public"], + deps = [ + "//googleapis/api/annotations", -+ "//googleapis/longrunning", ++ "@com_google_cloud_go_longrunning//autogen/longrunningpb:go_default_library", + "@org_golang_google_grpc//:go_default_library", + "@org_golang_google_grpc//codes:go_default_library", + "@org_golang_google_grpc//status:go_default_library", @@ -10150,9 +10150,9 @@ diff -urN a/googleapis/genomics/v1/BUILD.bazel b/googleapis/genomics/v1/BUILD.ba + visibility = ["//visibility:public"], + deps = [ + "//googleapis/api/annotations", -+ "//googleapis/iam/v1:iam", -+ "//googleapis/longrunning", + "//googleapis/rpc/status", ++ "@com_google_cloud_go_iam//apiv1/iampb:go_default_library", ++ "@com_google_cloud_go_longrunning//autogen/longrunningpb:go_default_library", + "@org_golang_google_grpc//:go_default_library", + "@org_golang_google_grpc//codes:go_default_library", + "@org_golang_google_grpc//status:go_default_library", @@ -10185,8 +10185,8 @@ diff -urN a/googleapis/genomics/v1alpha2/BUILD.bazel b/googleapis/genomics/v1alp + visibility = ["//visibility:public"], + deps = [ + "//googleapis/api/annotations", -+ "//googleapis/longrunning", + "//googleapis/rpc/code", ++ "@com_google_cloud_go_longrunning//autogen/longrunningpb:go_default_library", + "@org_golang_google_grpc//:go_default_library", + "@org_golang_google_grpc//codes:go_default_library", + "@org_golang_google_grpc//status:go_default_library", @@ -11066,7 +11066,7 @@ diff -urN a/googleapis/partner/aistreams/v1alpha1/BUILD.bazel b/googleapis/partn + visibility = ["//visibility:public"], + deps = [ + "//googleapis/api/annotations", -+ "//googleapis/longrunning", ++ "@com_google_cloud_go_longrunning//autogen/longrunningpb:go_default_library", + "@org_golang_google_grpc//:go_default_library", + "@org_golang_google_grpc//codes:go_default_library", + "@org_golang_google_grpc//status:go_default_library", diff --git a/third_party/org_golang_x_sys-gazelle.patch b/third_party/org_golang_x_sys-gazelle.patch index 4caedb682..6443063a4 100644 --- a/third_party/org_golang_x_sys-gazelle.patch +++ b/third_party/org_golang_x_sys-gazelle.patch @@ -150,7 +150,7 @@ diff -urN a/plan9/BUILD.bazel b/plan9/BUILD.bazel diff -urN a/unix/BUILD.bazel b/unix/BUILD.bazel --- a/unix/BUILD.bazel 1970-01-01 00:00:00.000000000 +0000 +++ b/unix/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -0,0 +1,301 @@ +@@ -0,0 +1,303 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( @@ -174,6 +174,7 @@ diff -urN a/unix/BUILD.bazel b/unix/BUILD.bazel + "asm_linux_s390x.s", + "asm_solaris_amd64.s", + "bluetooth_linux.go", ++ "bpxsvc_zos.s", + "cap_freebsd.go", + "constants.go", + "dev_aix_ppc64.go", @@ -209,6 +210,7 @@ diff -urN a/unix/BUILD.bazel b/unix/BUILD.bazel + "sockcmsg_linux.go", + "sockcmsg_unix.go", + "sockcmsg_unix_other.go", ++ "sockcmsg_zos.go", + "syscall.go", + "syscall_aix.go", + "syscall_aix_ppc64.go", @@ -479,7 +481,7 @@ diff -urN a/unix/internal/mkmerge/BUILD.bazel b/unix/internal/mkmerge/BUILD.baze diff -urN a/windows/BUILD.bazel b/windows/BUILD.bazel --- a/windows/BUILD.bazel 1970-01-01 00:00:00.000000000 +0000 +++ b/windows/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -0,0 +1,54 @@ +@@ -0,0 +1,53 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( @@ -487,7 +489,6 @@ diff -urN a/windows/BUILD.bazel b/windows/BUILD.bazel + srcs = [ + "aliases.go", + "dll_windows.go", -+ "empty.s", + "env_windows.go", + "eventlog.go", + "exec_windows.go", diff --git a/third_party/org_golang_x_tools-deletegopls.patch b/third_party/org_golang_x_tools-deletegopls.patch index 238e7146d..d75ccca0f 100644 --- a/third_party/org_golang_x_tools-deletegopls.patch +++ b/third_party/org_golang_x_tools-deletegopls.patch @@ -173,7 +173,7 @@ diff -urN a/gopls/doc/advanced.md b/gopls/doc/advanced.md diff -urN a/gopls/doc/analyzers.md b/gopls/doc/analyzers.md --- a/gopls/doc/analyzers.md 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/doc/analyzers.md 1970-01-01 00:00:00.000000000 +0000 -@@ -1,1035 +0,0 @@ +@@ -1,1008 +0,0 @@ -# Analyzers - -This document describes the analyzers that `gopls` uses inside the editor. @@ -729,40 +729,13 @@ diff -urN a/gopls/doc/analyzers.md b/gopls/doc/analyzers.md - -The check applies to calls of the formatting functions such as -[fmt.Printf] and [fmt.Sprintf], as well as any detected wrappers of --those functions. -- --In this example, the %d format operator requires an integer operand: -- -- fmt.Printf("%d", "hello") // fmt.Printf format %d has arg "hello" of wrong type string +-those functions such as [log.Printf]. It reports a variety of +-mistakes such as syntax errors in the format string and mismatches +-(of number and type) between the verbs and their arguments. - -See the documentation of the fmt package for the complete set of -format operators and their operand types. - --To enable printf checking on a function that is not found by this --analyzer's heuristics (for example, because control is obscured by --dynamic method calls), insert a bogus call: -- -- func MyPrintf(format string, args ...any) { -- if false { -- _ = fmt.Sprintf(format, args...) // enable printf checker -- } -- ... -- } -- --The -funcs flag specifies a comma-separated list of names of additional --known formatting functions or methods. If the name contains a period, --it must denote a specific function using one of the following forms: -- -- dir/pkg.Function -- dir/pkg.Type.Method -- (*dir/pkg.Type).Method -- --Otherwise the name is interpreted as a case-insensitive unqualified --identifier such as "errorf". Either way, if a listed name ends in f, the --function is assumed to be Printf-like, taking a format string before the --argument list. Otherwise it is assumed to be Print-like, taking a list --of arguments with no format string. -- -[Full documentation](https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/printf) - -**Enabled by default.** @@ -1231,7 +1204,7 @@ diff -urN a/gopls/doc/command-line.md b/gopls/doc/command-line.md diff -urN a/gopls/doc/commands.md b/gopls/doc/commands.md --- a/gopls/doc/commands.md 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/doc/commands.md 1970-01-01 00:00:00.000000000 +0000 -@@ -1,749 +0,0 @@ +@@ -1,750 +0,0 @@ -# Commands - -This document describes the LSP-level commands supported by `gopls`. They cannot be invoked directly by users, and all the details are subject to change, so nobody should rely on this information. @@ -1937,6 +1910,7 @@ diff -urN a/gopls/doc/commands.md b/gopls/doc/commands.md - -``` -[]{ +- "ID": string, - "Type": string, - "Root": string, - "Folder": string, @@ -3305,14 +3279,11 @@ diff -urN a/gopls/doc/features.md b/gopls/doc/features.md diff -urN a/gopls/doc/generate.go b/gopls/doc/generate.go --- a/gopls/doc/generate.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/doc/generate.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,783 +0,0 @@ +@@ -1,789 +0,0 @@ -// Copyright 2020 The Go Authors. All rights reserved. -// 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 @@ -3356,6 +3327,14 @@ diff -urN a/gopls/doc/generate.go b/gopls/doc/generate.go -} - -func doMain(write bool) (bool, error) { +- // TODO(adonovan): when we can rely on go1.23, +- // switch to gotypesalias=1 behavior. +- // +- // (Since this program is run by 'go run', +- // the gopls/go.mod file's go 1.19 directive doesn't +- // have its usual effect of setting gotypesalias=0.) +- os.Setenv("GODEBUG", "gotypesalias=0") +- - api, err := loadAPI() - if err != nil { - return false, err @@ -3419,7 +3398,7 @@ diff -urN a/gopls/doc/generate.go b/gopls/doc/generate.go - defaults := settings.DefaultOptions() - api := &settings.APIJSON{ - Options: map[string][]*settings.OptionJSON{}, -- Analyzers: loadAnalyzers(defaults.DefaultAnalyzers), // no staticcheck analyzers +- Analyzers: loadAnalyzers(settings.DefaultAnalyzers), // no staticcheck analyzers - } - - api.Commands, err = loadCommands() @@ -3759,6 +3738,7 @@ diff -urN a/gopls/doc/generate.go b/gopls/doc/generate.go - case *types.Slice: - return fmt.Sprintf("[]%s", u.Elem().Underlying().String()) - } +- // TODO(adonovan): use (*types.Package).Name qualifier. - return types.TypeString(under, nil) -} - @@ -3816,17 +3796,17 @@ diff -urN a/gopls/doc/generate.go b/gopls/doc/generate.go -func loadAnalyzers(m map[string]*settings.Analyzer) []*settings.AnalyzerJSON { - var sorted []string - for _, a := range m { -- sorted = append(sorted, a.Analyzer.Name) +- sorted = append(sorted, a.Analyzer().Name) - } - sort.Strings(sorted) - var json []*settings.AnalyzerJSON - for _, name := range sorted { - a := m[name] - json = append(json, &settings.AnalyzerJSON{ -- Name: a.Analyzer.Name, -- Doc: a.Analyzer.Doc, -- URL: a.Analyzer.URL, -- Default: a.Enabled, +- Name: a.Analyzer().Name, +- Doc: a.Analyzer().Doc, +- URL: a.Analyzer().URL, +- Default: a.EnabledByDefault(), - }) - } - return json @@ -4444,13 +4424,23 @@ diff -urN a/gopls/doc/release/README b/gopls/doc/release/README diff -urN a/gopls/doc/release/v0.16.0.md b/gopls/doc/release/v0.16.0.md --- a/gopls/doc/release/v0.16.0.md 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/doc/release/v0.16.0.md 1970-01-01 00:00:00.000000000 +0000 -@@ -1,93 +0,0 @@ +@@ -1,124 +0,0 @@ -gopls/v0.16.0 - -``` -go install golang.org/x/tools/gopls@v0.16.0 -``` - +-## Configuration Changes +- +-- The default value of the "semanticTokens" setting is now "true". This means +- that if your LSP client is able and configured to request semantic tokens, +- gopls will provide them. The default was previously false because VS Code +- historically provided no client-side way for users to disable the feature. +-- The experimental "allowImplicitNetworkAccess" setting is deprecated (but not +- yet removed). Please comment on https://go.dev/issue/66861 if you use this +- setting and would be impacted by its removal. +- -## New features - -### Integrated documentation viewer @@ -4532,13 +4522,33 @@ diff -urN a/gopls/doc/release/v0.16.0.md b/gopls/doc/release/v0.16.0.md - -TODO: example hover image. - +-### Hover and definition on doc links +- +-Go 1.19 added support for [links in doc +-comments](https://go.dev/doc/comment#links), allowing the +-documentation for one symbol to reference another: +- +-TODO: turn the code below into a VS Code screenshot of hover. +- +-```go +-// Logf logs a message formatted in the manner of [fmt.Printf]. +-func Logf(format string, args ...any) +-``` +- +-Gopls's Hover and Definition operations now treat these links just +-like identifiers, so hovering over one will display information about +-the symbol, and "Go to definition" will navigate to its declaration. +-Thanks to @rogeryk for contributing this feature. +- +- -## Bugs fixed - -## Thank you to our contributors! - -@guodongli-google for the `unusedwrite` analyzer. -TODO: they're a xoogler; is there a more current GH account? -\ No newline at end of file +- +-@rogeryk diff -urN a/gopls/doc/releases.md b/gopls/doc/releases.md --- a/gopls/doc/releases.md 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/doc/releases.md 1970-01-01 00:00:00.000000000 +0000 @@ -4697,7 +4707,7 @@ diff -urN a/gopls/doc/semantictokens.md b/gopls/doc/semantictokens.md diff -urN a/gopls/doc/settings.md b/gopls/doc/settings.md --- a/gopls/doc/settings.md 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/doc/settings.md 1970-01-01 00:00:00.000000000 +0000 -@@ -1,573 +0,0 @@ +@@ -1,564 +0,0 @@ -# Settings - - @@ -4808,15 +4818,6 @@ diff -urN a/gopls/doc/settings.md b/gopls/doc/settings.md - -Default: `true`. - --#### **allowModfileModifications** *bool* -- --**This setting is experimental and may be deleted.** -- --allowModfileModifications disables -mod=readonly, allowing imports from --out-of-scope modules. This option will eventually be removed. -- --Default: `false`. -- -#### **allowImplicitNetworkAccess** *bool* - -**This setting is experimental and may be deleted.** @@ -4896,9 +4897,10 @@ diff -urN a/gopls/doc/settings.md b/gopls/doc/settings.md -**This setting is experimental and may be deleted.** - -semanticTokens controls whether the LSP server will send --semantic tokens to the client. +-semantic tokens to the client. If false, gopls will send empty semantic +-tokens. - --Default: `false`. +-Default: `true`. - -#### **noSemanticString** *bool* - @@ -5189,10 +5191,9 @@ diff -urN a/gopls/doc/settings.md b/gopls/doc/settings.md -##### **symbolScope** *enum* - -symbolScope controls which packages are searched for workspace/symbol --requests. The default value, "workspace", searches only workspace --packages. The legacy behavior, "all", causes all loaded packages to be --searched, including dependencies; this is more expensive and may return --unwanted results. +-requests. When the scope is "workspace", gopls searches only workspace +-packages. When the scope is "all", gopls searches all loaded packages, +-including dependencies and the standard library. - -Must be one of: - @@ -5796,7 +5797,7 @@ diff -urN a/gopls/go.mod b/gopls/go.mod @@ -1,30 +0,0 @@ -module golang.org/x/tools/gopls - --go 1.19 +-go 1.19 // => default GODEBUG has gotypesalias=0 - -require ( - github.com/google/go-cmp v0.6.0 @@ -5805,7 +5806,7 @@ diff -urN a/gopls/go.mod b/gopls/go.mod - golang.org/x/mod v0.17.0 - golang.org/x/sync v0.7.0 - golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2 -- golang.org/x/text v0.14.0 +- golang.org/x/text v0.15.0 - golang.org/x/tools v0.18.0 - golang.org/x/vuln v1.0.4 - gopkg.in/yaml.v3 v3.0.1 @@ -5818,7 +5819,7 @@ diff -urN a/gopls/go.mod b/gopls/go.mod - github.com/BurntSushi/toml v1.2.1 // indirect - github.com/google/safehtml v0.1.0 // indirect - golang.org/x/exp/typeparams v0.0.0-20221212164502-fae10dda9338 // indirect -- golang.org/x/sys v0.19.0 // indirect +- golang.org/x/sys v0.20.0 // indirect - gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect - -) @@ -5827,7 +5828,7 @@ diff -urN a/gopls/go.mod b/gopls/go.mod diff -urN a/gopls/go.sum b/gopls/go.sum --- a/gopls/go.sum 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/go.sum 1970-01-01 00:00:00.000000000 +0000 -@@ -1,56 +0,0 @@ +@@ -1,57 +0,0 @@ -github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= -github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= -github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= @@ -5844,7 +5845,7 @@ diff -urN a/gopls/go.sum b/gopls/go.sum -github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= --golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +-golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= -golang.org/x/exp/typeparams v0.0.0-20221212164502-fae10dda9338 h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y= -golang.org/x/exp/typeparams v0.0.0-20221212164502-fae10dda9338/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= @@ -5853,24 +5854,25 @@ diff -urN a/gopls/go.sum b/gopls/go.sum -golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= --golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= +-golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= --golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= --golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +-golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= +-golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2 h1:IRJeR9r1pYWsHKTRe/IInb7lYvbBVIqOgsX/u0mbOWY= -golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= -golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= --golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= +-golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= --golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +-golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= +-golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/vuln v1.0.4 h1:SP0mPeg2PmGCu03V+61EcQiOjmpri2XijexKdzv8Z1I= -golang.org/x/vuln v1.0.4/go.mod h1:NbJdUQhX8jY++FtuhrXs2Eyx0yePo9pF7nPlIjo9aaQ= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -7290,7 +7292,7 @@ diff -urN a/gopls/internal/analysis/fillreturns/fillreturns.go b/gopls/internal/ diff -urN a/gopls/internal/analysis/fillreturns/fillreturns_test.go b/gopls/internal/analysis/fillreturns/fillreturns_test.go --- a/gopls/internal/analysis/fillreturns/fillreturns_test.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/analysis/fillreturns/fillreturns_test.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,24 +0,0 @@ +@@ -1,25 +0,0 @@ -// Copyright 2020 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -7298,18 +7300,19 @@ diff -urN a/gopls/internal/analysis/fillreturns/fillreturns_test.go b/gopls/inte -package fillreturns_test - -import ( -- "os" -- "strings" - "testing" - - "golang.org/x/tools/go/analysis/analysistest" - "golang.org/x/tools/gopls/internal/analysis/fillreturns" +- "golang.org/x/tools/internal/aliases" -) - -func Test(t *testing.T) { -- // TODO(golang/go#65294): delete once gotypesalias=1 is the default. -- if strings.Contains(os.Getenv("GODEBUG"), "gotypesalias=1") { -- t.Skip("skipping due to gotypesalias=1, which changes (improves) the result; reenable and update the expectations once it is the default") +- // TODO(golang/go#65294): update expectations and delete this +- // check once we update go.mod to go1.23 so that +- // gotypesalias=1 becomes the only supported mode. +- if aliases.Enabled() { +- t.Skip("expectations need updating for materialized aliases") - } - - testdata := analysistest.TestData() @@ -7601,18 +7604,18 @@ diff -urN a/gopls/internal/analysis/fillreturns/testdata/src/a/a.go.golden b/gop - var b bool - return int, "", n, b, nil // want "return values" -} -diff -urN a/gopls/internal/analysis/fillreturns/testdata/src/a/typeparams/a.go b/gopls/internal/analysis/fillreturns/testdata/src/a/typeparams/a.go ---- a/gopls/internal/analysis/fillreturns/testdata/src/a/typeparams/a.go 2000-01-01 00:00:00.000000000 -0000 -+++ b/gopls/internal/analysis/fillreturns/testdata/src/a/typeparams/a.go 1970-01-01 00:00:00.000000000 +0000 +diff -urN a/gopls/internal/analysis/fillreturns/testdata/src/typeparams/a.go b/gopls/internal/analysis/fillreturns/testdata/src/typeparams/a.go +--- a/gopls/internal/analysis/fillreturns/testdata/src/typeparams/a.go 2000-01-01 00:00:00.000000000 -0000 ++++ b/gopls/internal/analysis/fillreturns/testdata/src/typeparams/a.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -package fillreturns - -func hello[T any]() int { - return -} -diff -urN a/gopls/internal/analysis/fillreturns/testdata/src/a/typeparams/a.go.golden b/gopls/internal/analysis/fillreturns/testdata/src/a/typeparams/a.go.golden ---- a/gopls/internal/analysis/fillreturns/testdata/src/a/typeparams/a.go.golden 2000-01-01 00:00:00.000000000 -0000 -+++ b/gopls/internal/analysis/fillreturns/testdata/src/a/typeparams/a.go.golden 1970-01-01 00:00:00.000000000 +0000 +diff -urN a/gopls/internal/analysis/fillreturns/testdata/src/typeparams/a.go.golden b/gopls/internal/analysis/fillreturns/testdata/src/typeparams/a.go.golden +--- a/gopls/internal/analysis/fillreturns/testdata/src/typeparams/a.go.golden 2000-01-01 00:00:00.000000000 -0000 ++++ b/gopls/internal/analysis/fillreturns/testdata/src/typeparams/a.go.golden 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -package fillreturns - @@ -11333,7 +11336,7 @@ diff -urN a/gopls/internal/analysis/stubmethods/stubmethods_test.go b/gopls/inte - -func Test(t *testing.T) { - testdata := analysistest.TestData() -- analysistest.Run(t, testdata, stubmethods.Analyzer, "a") +- analysistest.Run(t, testdata, stubmethods.Analyzer, "typeparams") -} diff -urN a/gopls/internal/analysis/stubmethods/testdata/src/typeparams/implement.go b/gopls/internal/analysis/stubmethods/testdata/src/typeparams/implement.go --- a/gopls/internal/analysis/stubmethods/testdata/src/typeparams/implement.go 2000-01-01 00:00:00.000000000 -0000 @@ -11345,7 +11348,7 @@ diff -urN a/gopls/internal/analysis/stubmethods/testdata/src/typeparams/implemen - -package stubmethods - --var _ I = Y{} // want "Implement I" +-var _ I = Y{} // want "does not implement I" - -type I interface{ F() } - @@ -13348,7 +13351,7 @@ diff -urN a/gopls/internal/analysis/useany/useany_test.go b/gopls/internal/analy diff -urN a/gopls/internal/cache/analysis.go b/gopls/internal/cache/analysis.go --- a/gopls/internal/cache/analysis.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/cache/analysis.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,1581 +0,0 @@ +@@ -1,1614 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -13387,14 +13390,16 @@ diff -urN a/gopls/internal/cache/analysis.go b/gopls/internal/cache/analysis.go - "golang.org/x/tools/gopls/internal/cache/parsego" - "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/filecache" +- "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/gopls/internal/progress" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/settings" - "golang.org/x/tools/gopls/internal/util/astutil" - "golang.org/x/tools/gopls/internal/util/bug" - "golang.org/x/tools/gopls/internal/util/frob" +- "golang.org/x/tools/gopls/internal/util/maps" +- "golang.org/x/tools/internal/analysisinternal" - "golang.org/x/tools/internal/event" -- "golang.org/x/tools/internal/event/tag" - "golang.org/x/tools/internal/facts" - "golang.org/x/tools/internal/gcimporter" - "golang.org/x/tools/internal/typesinternal" @@ -13529,8 +13534,6 @@ diff -urN a/gopls/internal/cache/analysis.go b/gopls/internal/cache/analysis.go - - var tagStr string // sorted comma-separated list of PackageIDs - { -- // TODO(adonovan): replace with a generic map[S]any -> string -- // function in the tag package, and use maps.Keys + slices.Sort. - keys := make([]string, 0, len(pkgs)) - for id := range pkgs { - keys = append(keys, string(id)) @@ -13538,36 +13541,36 @@ diff -urN a/gopls/internal/cache/analysis.go b/gopls/internal/cache/analysis.go - sort.Strings(keys) - tagStr = strings.Join(keys, ",") - } -- ctx, done := event.Start(ctx, "snapshot.Analyze", tag.Package.Of(tagStr)) +- ctx, done := event.Start(ctx, "snapshot.Analyze", label.Package.Of(tagStr)) - defer done() - - // Filter and sort enabled root analyzers. - // A disabled analyzer may still be run if required by another. - toSrc := make(map[*analysis.Analyzer]*settings.Analyzer) -- var enabled []*analysis.Analyzer // enabled subset + transitive requirements +- var enabledAnalyzers []*analysis.Analyzer // enabled subset + transitive requirements - for _, a := range analyzers { -- if a.IsEnabled(s.Options()) { -- toSrc[a.Analyzer] = a -- enabled = append(enabled, a.Analyzer) +- if enabled, ok := s.Options().Analyses[a.Analyzer().Name]; enabled || !ok && a.EnabledByDefault() { +- toSrc[a.Analyzer()] = a +- enabledAnalyzers = append(enabledAnalyzers, a.Analyzer()) - } - } -- sort.Slice(enabled, func(i, j int) bool { -- return enabled[i].Name < enabled[j].Name +- sort.Slice(enabledAnalyzers, func(i, j int) bool { +- return enabledAnalyzers[i].Name < enabledAnalyzers[j].Name - }) - analyzers = nil // prevent accidental use - -- enabled = requiredAnalyzers(enabled) +- enabledAnalyzers = requiredAnalyzers(enabledAnalyzers) - - // Perform basic sanity checks. - // (Ideally we would do this only once.) -- if err := analysis.Validate(enabled); err != nil { +- if err := analysis.Validate(enabledAnalyzers); err != nil { - return nil, fmt.Errorf("invalid analyzer configuration: %v", err) - } - - stableNames := make(map[*analysis.Analyzer]string) - - var facty []*analysis.Analyzer // facty subset of enabled + transitive requirements -- for _, a := range enabled { +- for _, a := range enabledAnalyzers { - // TODO(adonovan): reject duplicate stable names (very unlikely). - stableNames[a] = stableName(a) - @@ -13655,10 +13658,10 @@ diff -urN a/gopls/internal/cache/analysis.go b/gopls/internal/cache/analysis.go - } - // Add edge from predecessor. - if from != nil { -- atomic.AddInt32(&from.unfinishedSuccs, 1) // TODO(adonovan): use generics +- from.unfinishedSuccs.Add(+1) // incref - an.preds = append(an.preds, from) - } -- atomic.AddInt32(&an.unfinishedPreds, 1) +- an.unfinishedPreds.Add(+1) - return an, nil - } - @@ -13669,7 +13672,7 @@ diff -urN a/gopls/internal/cache/analysis.go b/gopls/internal/cache/analysis.go - if err != nil { - return nil, err - } -- root.analyzers = enabled +- root.analyzers = enabledAnalyzers - roots = append(roots, root) - } - @@ -13739,7 +13742,7 @@ diff -urN a/gopls/internal/cache/analysis.go b/gopls/internal/cache/analysis.go - // prevents workers from enqeuing, and thus finishing, and thus allowing the - // group to make progress: deadlock. - limiter := make(chan unit, runtime.GOMAXPROCS(0)) -- var completed int64 +- var completed atomic.Int64 - - var enqueue func(*analysisNode) - enqueue = func(an *analysisNode) { @@ -13751,13 +13754,13 @@ diff -urN a/gopls/internal/cache/analysis.go b/gopls/internal/cache/analysis.go - if err != nil { - return err // cancelled, or failed to produce a package - } -- maybeReport(atomic.AddInt64(&completed, 1)) +- maybeReport(completed.Add(1)) - an.summary = summary - - // Notify each waiting predecessor, - // and enqueue it when it becomes a leaf. - for _, pred := range an.preds { -- if atomic.AddInt32(&pred.unfinishedSuccs, -1) == 0 { +- if pred.unfinishedSuccs.Add(-1) == 0 { // decref - enqueue(pred) - } - } @@ -13779,6 +13782,18 @@ diff -urN a/gopls/internal/cache/analysis.go b/gopls/internal/cache/analysis.go - return nil, err // cancelled, or failed to produce a package - } - +- // Inv: all root nodes now have a summary (#66732). +- // +- // We know this is falsified empirically. This means either +- // the summary was "successfully" set to nil (above), or there +- // is a problem with the graph such the enqueuing leaves does +- // not lead to completion of roots (or an error). +- for _, root := range roots { +- if root.summary == nil { +- bug.Report("root analysisNode has nil summary") +- } +- } +- - // Report diagnostics only from enabled actions that succeeded. - // Errors from creating or analyzing packages are ignored. - // Diagnostics are reported in the order of the analyzers argument. @@ -13791,7 +13806,7 @@ diff -urN a/gopls/internal/cache/analysis.go b/gopls/internal/cache/analysis.go - // results, we should propagate the per-action errors. - var results []*Diagnostic - for _, root := range roots { -- for _, a := range enabled { +- for _, a := range enabledAnalyzers { - // Skip analyzers that were added only to - // fulfil requirements of the original set. - srcAnalyzer, ok := toSrc[a] @@ -13810,6 +13825,7 @@ diff -urN a/gopls/internal/cache/analysis.go b/gopls/internal/cache/analysis.go - } - - // Inv: root.summary is the successful result of run (via runCached). +- // TODO(adonovan): fix: root.summary is sometimes nil! (#66732). - summary, ok := root.summary.Actions[stableNames[a]] - if summary == nil { - panic(fmt.Sprintf("analyzeSummary.Actions[%q] = (nil, %t); got %v (#60551)", @@ -13827,7 +13843,7 @@ diff -urN a/gopls/internal/cache/analysis.go b/gopls/internal/cache/analysis.go -} - -func (an *analysisNode) decrefPreds() { -- if atomic.AddInt32(&an.unfinishedPreds, -1) == 0 { +- if an.unfinishedPreds.Add(-1) == 0 { - an.summary.Actions = nil - } -} @@ -13862,8 +13878,8 @@ diff -urN a/gopls/internal/cache/analysis.go b/gopls/internal/cache/analysis.go - analyzers []*analysis.Analyzer // set of analyzers to run - preds []*analysisNode // graph edges: - succs map[PackageID]*analysisNode // (preds -> self -> succs) -- unfinishedSuccs int32 -- unfinishedPreds int32 // effectively a summary.Actions refcount +- unfinishedSuccs atomic.Int32 +- unfinishedPreds atomic.Int32 // effectively a summary.Actions refcount - allDeps map[PackagePath]*analysisNode // all dependencies including self - exportDeps map[PackagePath]*analysisNode // subset of allDeps ref'd by export data (+self) - summary *analyzeSummary // serializable result of analyzing this package @@ -14016,6 +14032,9 @@ diff -urN a/gopls/internal/cache/analysis.go b/gopls/internal/cache/analysis.go - if data, err := filecache.Get(cacheKind, key); err == nil { - // cache hit - analyzeSummaryCodec.Decode(data, &summary) +- if summary == nil { // debugging #66732 +- bug.Reportf("analyzeSummaryCodec.Decode yielded nil *analyzeSummary") +- } - } else if err != filecache.ErrNotFound { - return nil, bug.Errorf("internal error reading shared cache: %v", err) - } else { @@ -14025,8 +14044,11 @@ diff -urN a/gopls/internal/cache/analysis.go b/gopls/internal/cache/analysis.go - if err != nil { - return nil, err - } +- if summary == nil { // debugging #66732 (can't happen) +- bug.Reportf("analyzeNode.run returned nil *analyzeSummary") +- } - -- atomic.AddInt32(&an.unfinishedPreds, +1) // incref +- an.unfinishedPreds.Add(+1) // incref - go func() { - defer an.decrefPreds() //decref - @@ -14094,13 +14116,11 @@ diff -urN a/gopls/internal/cache/analysis.go b/gopls/internal/cache/analysis.go - } - - // vdeps, in PackageID order -- depIDs := make([]string, 0, len(an.succs)) -- for depID := range an.succs { -- depIDs = append(depIDs, string(depID)) -- } -- sort.Strings(depIDs) // TODO(adonovan): avoid conversions by using slices.Sort[PackageID] +- depIDs := maps.Keys(an.succs) +- // TODO(adonovan): use go1.2x slices.Sort(depIDs). +- sort.Slice(depIDs, func(i, j int) bool { return depIDs[i] < depIDs[j] }) - for _, depID := range depIDs { -- vdep := an.succs[PackageID(depID)] +- vdep := an.succs[depID] - fmt.Fprintf(hasher, "dep: %s\n", vdep.mp.PkgPath) - fmt.Fprintf(hasher, "export: %s\n", vdep.summary.DeepExportHash) - @@ -14640,11 +14660,24 @@ diff -urN a/gopls/internal/cache/analysis.go b/gopls/internal/cache/analysis.go - } - - // debugging #64547 -- if start < token.Pos(tokFile.Base()) { +- fileStart := token.Pos(tokFile.Base()) +- fileEnd := fileStart + token.Pos(tokFile.Size()) +- if start < fileStart { - bug.Reportf("start < start of file") -- } -- if end > token.Pos(tokFile.Base()+tokFile.Size()+1) { +- start = fileStart +- } +- if end < start { +- // This can happen if End is zero (#66683) +- // or a small positive displacement from zero +- // due to recursively Node.End() computation. +- // This usually arises from poor parser recovery +- // of an incomplete term at EOF. +- bug.Reportf("end < start of file") +- end = fileEnd +- } +- if end > fileEnd+1 { - bug.Reportf("end > end of file + 1") +- end = fileEnd - } - - return p.PosLocation(start, end) @@ -14685,6 +14718,9 @@ diff -urN a/gopls/internal/cache/analysis.go b/gopls/internal/cache/analysis.go - AllObjectFacts: func() []analysis.ObjectFact { return factset.AllObjectFacts(factFilter) }, - AllPackageFacts: func() []analysis.PackageFact { return factset.AllPackageFacts(factFilter) }, - } +- // TODO(adonovan): integrate this into the snapshot's file +- // cache and its dependency analysis. +- pass.ReadFile = analysisinternal.MakeReadFile(pass) - - // Recover from panics (only) within the analyzer logic. - // (Use an anonymous function to limit the recover scope.) @@ -15013,7 +15049,7 @@ diff -urN a/gopls/internal/cache/cache.go b/gopls/internal/cache/cache.go diff -urN a/gopls/internal/cache/check.go b/gopls/internal/cache/check.go --- a/gopls/internal/cache/check.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/cache/check.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,1991 +0,0 @@ +@@ -1,2021 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -15044,13 +15080,13 @@ diff -urN a/gopls/internal/cache/check.go b/gopls/internal/cache/check.go - "golang.org/x/tools/gopls/internal/cache/typerefs" - "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/filecache" +- "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/util/bug" - "golang.org/x/tools/gopls/internal/util/safetoken" - "golang.org/x/tools/gopls/internal/util/slices" - "golang.org/x/tools/internal/analysisinternal" - "golang.org/x/tools/internal/event" -- "golang.org/x/tools/internal/event/tag" - "golang.org/x/tools/internal/gcimporter" - "golang.org/x/tools/internal/packagesinternal" - "golang.org/x/tools/internal/tokeninternal" @@ -15078,7 +15114,7 @@ diff -urN a/gopls/internal/cache/check.go b/gopls/internal/cache/check.go - syntaxIndex map[PackageID]int // requested ID -> index in ids - pre preTypeCheck - post postTypeCheck -- handles map[PackageID]*packageHandle +- handles map[PackageID]*packageHandle // (immutable) - parseCache *parseCache - fset *token.FileSet // describes all parsed or imported files - cpulimit chan unit // concurrency limiter for CPU-bound operations @@ -15185,7 +15221,10 @@ diff -urN a/gopls/internal/cache/check.go b/gopls/internal/cache/check.go - defer release() - importGraph, err := s.resolveImportGraph() // may be nil - if err != nil { -- if ctx.Err() == nil { +- // resolveImportGraph operates on the background context, because it is +- // a shared resource across the snapshot. If the snapshot is cancelled, +- // don't log an error. +- if s.backgroundCtx.Err() == nil { - event.Error(ctx, "computing the shared import graph", err) - } - importGraph = nil @@ -15360,7 +15399,7 @@ diff -urN a/gopls/internal/cache/check.go b/gopls/internal/cache/check.go -// -// Both pre and post may be called concurrently. -func (s *Snapshot) forEachPackage(ctx context.Context, ids []PackageID, pre preTypeCheck, post postTypeCheck) error { -- ctx, done := event.Start(ctx, "cache.forEachPackage", tag.PackageCount.Of(len(ids))) +- ctx, done := event.Start(ctx, "cache.forEachPackage", label.PackageCount.Of(len(ids))) - defer done() - - if len(ids) == 0 { @@ -15486,6 +15525,7 @@ diff -urN a/gopls/internal/cache/check.go b/gopls/internal/cache/check.go - - // Do a second check for "unsafe" defensively, due to golang/go#60890. - if ph.mp.PkgPath == "unsafe" { +- // (This assertion is reached.) - bug.Reportf("encountered \"unsafe\" as %s (golang/go#60890)", id) - return types.Unsafe, nil - } @@ -15624,7 +15664,7 @@ diff -urN a/gopls/internal/cache/check.go b/gopls/internal/cache/check.go -// importPackage loads the given package from its export data in p.exportData -// (which must already be populated). -func (b *typeCheckBatch) importPackage(ctx context.Context, mp *metadata.Package, data []byte) (*types.Package, error) { -- ctx, done := event.Start(ctx, "cache.typeCheckBatch.importPackage", tag.Package.Of(string(mp.ID))) +- ctx, done := event.Start(ctx, "cache.typeCheckBatch.importPackage", label.Package.Of(string(mp.ID))) - defer done() - - impMap := b.importMap(mp.ID) @@ -15690,7 +15730,7 @@ diff -urN a/gopls/internal/cache/check.go b/gopls/internal/cache/check.go -// checkPackageForImport type checks, but skips function bodies and does not -// record syntax information. -func (b *typeCheckBatch) checkPackageForImport(ctx context.Context, ph *packageHandle) (*types.Package, error) { -- ctx, done := event.Start(ctx, "cache.typeCheckBatch.checkPackageForImport", tag.Package.Of(string(ph.mp.ID))) +- ctx, done := event.Start(ctx, "cache.typeCheckBatch.checkPackageForImport", label.Package.Of(string(ph.mp.ID))) - defer done() - - onError := func(e error) { @@ -15970,6 +16010,11 @@ diff -urN a/gopls/internal/cache/check.go b/gopls/internal/cache/check.go - for _, v := range b.nodes { - assert(v.ph != nil, "nil handle") - handles[v.mp.ID] = v.ph +- +- // debugging #60890 +- if v.ph.mp.PkgPath == "unsafe" && v.mp.ID != "unsafe" { +- bug.Reportf("PackagePath \"unsafe\" with ID %q", v.mp.ID) +- } - } - - return handles, nil @@ -16476,7 +16521,7 @@ diff -urN a/gopls/internal/cache/check.go b/gopls/internal/cache/check.go -// deps holds the future results of type-checking the direct dependencies. -func (b *typeCheckBatch) checkPackage(ctx context.Context, ph *packageHandle) (*Package, error) { - inputs := ph.localInputs -- ctx, done := event.Start(ctx, "cache.typeCheckBatch.checkPackage", tag.Package.Of(string(inputs.id))) +- ctx, done := event.Start(ctx, "cache.typeCheckBatch.checkPackage", label.Package.Of(string(inputs.id))) - defer done() - - pkg := &syntaxPackage{ @@ -16593,7 +16638,7 @@ diff -urN a/gopls/internal/cache/check.go b/gopls/internal/cache/check.go - for _, e := range pkg.parseErrors { - diags, err := parseErrorDiagnostics(pkg, e) - if err != nil { -- event.Error(ctx, "unable to compute positions for parse errors", err, tag.Package.Of(string(inputs.id))) +- event.Error(ctx, "unable to compute positions for parse errors", err, label.Package.Of(string(inputs.id))) - continue - } - for _, diag := range diags { @@ -16670,6 +16715,10 @@ diff -urN a/gopls/internal/cache/check.go b/gopls/internal/cache/check.go - return false // malformed version string - } - +- if relVer := releaseVersion(); relVer != "" && versions.Before(versions.Lang(relVer), versions.Lang(goVersion)) { +- return false // 'go list' is too new for go/types +- } +- - // TODO(rfindley): remove once we no longer support building gopls with Go - // 1.20 or earlier. - if !slices.Contains(build.Default.ReleaseTags, "go1.21") && strings.Count(goVersion, ".") >= 2 { @@ -16679,6 +16728,19 @@ diff -urN a/gopls/internal/cache/check.go b/gopls/internal/cache/check.go - return true -} - +-// releaseVersion reports the Go language version used to compile gopls, or "" +-// if it cannot be determined. +-func releaseVersion() string { +- if len(build.Default.ReleaseTags) > 0 { +- v := build.Default.ReleaseTags[len(build.Default.ReleaseTags)-1] +- var dummy int +- if _, err := fmt.Sscanf(v, "go1.%d", &dummy); err == nil { +- return v +- } +- } +- return "" +-} +- -// depsErrors creates diagnostics for each metadata error (e.g. import cycle). -// These may be attached to import declarations in the transitive source files -// of pkg, or to 'requires' declarations in the package's go.mod file. @@ -16848,6 +16910,7 @@ diff -urN a/gopls/internal/cache/check.go b/gopls/internal/cache/check.go - var result []*Diagnostic - - // batch records diagnostics for a set of related types.Errors. +- // (related[0] is the primary error.) - batch := func(related []types.Error) { - var diags []*Diagnostic - for i, e := range related { @@ -16931,7 +16994,7 @@ diff -urN a/gopls/internal/cache/check.go b/gopls/internal/cache/check.go - bug.Reportf("internal error: could not compute pos to range for %v: %v", e, err) - continue - } -- msg := related[0].Msg +- msg := related[0].Msg // primary - if i > 0 { - if supportsRelatedInformation { - msg += " (see details)" @@ -16967,7 +17030,10 @@ diff -urN a/gopls/internal/cache/check.go b/gopls/internal/cache/check.go - // This is because go/types assumes that errors are read top-down, such as - // in the cycle error "A refers to...". The structure of the secondary - // error set likely only makes sense for the primary error. -- if i > 0 { +- // +- // NOTE: len(diags) == 0 if the primary diagnostic has invalid positions. +- // See also golang/go#66731. +- if i > 0 && len(diags) > 0 { - primary := diags[0] - primary.Related = append(primary.Related, protocol.DiagnosticRelatedInformation{ - Location: protocol.Location{URI: diag.URI, Range: diag.Range}, @@ -17695,7 +17761,7 @@ diff -urN a/gopls/internal/cache/errors.go b/gopls/internal/cache/errors.go - related = append(related, protocol.DiagnosticRelatedInformation(gobRelated)) - } - -- severity := srcAnalyzer.Severity +- severity := srcAnalyzer.Severity() - if severity == 0 { - severity = protocol.SeverityWarning - } @@ -17709,7 +17775,7 @@ diff -urN a/gopls/internal/cache/errors.go b/gopls/internal/cache/errors.go - Source: DiagnosticSource(gobDiag.Source), - Message: gobDiag.Message, - Related: related, -- Tags: srcAnalyzer.Tag, +- Tags: srcAnalyzer.Tags(), - } - - // We cross the set of fixes (whether edit- or command-based) @@ -17717,7 +17783,7 @@ diff -urN a/gopls/internal/cache/errors.go b/gopls/internal/cache/errors.go - // than one kind of action (e.g. refactor, quickfix, fixall), - // each corresponding to a distinct client UI element - // or operation. -- kinds := srcAnalyzer.ActionKinds +- kinds := srcAnalyzer.ActionKinds() - if len(kinds) == 0 { - kinds = []protocol.CodeActionKind{protocol.QuickFix} - } @@ -18440,9 +18506,9 @@ diff -urN a/gopls/internal/cache/fs_memoized.go b/gopls/internal/cache/fs_memoiz - "time" - - "golang.org/x/tools/gopls/internal/file" +- "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/internal/event" -- "golang.org/x/tools/internal/event/tag" - "golang.org/x/tools/internal/robustio" -) - @@ -18578,7 +18644,7 @@ diff -urN a/gopls/internal/cache/fs_memoized.go b/gopls/internal/cache/fs_memoiz - } - defer func() { <-ioLimit }() - -- ctx, done := event.Start(ctx, "cache.readFile", tag.File.Of(uri.Path())) +- ctx, done := event.Start(ctx, "cache.readFile", label.File.Of(uri.Path())) - _ = ctx - defer done() - @@ -18698,9 +18764,9 @@ diff -urN a/gopls/internal/cache/imports.go b/gopls/internal/cache/imports.go - "time" - - "golang.org/x/tools/gopls/internal/file" +- "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/internal/event" - "golang.org/x/tools/internal/event/keys" -- "golang.org/x/tools/internal/event/tag" - "golang.org/x/tools/internal/imports" -) - @@ -18782,7 +18848,7 @@ diff -urN a/gopls/internal/cache/imports.go b/gopls/internal/cache/imports.go - timer, ok := c.timers[dir] - if !ok { - timer = newRefreshTimer(func() { -- _, done := event.Start(ctx, "cache.sharedModCache.refreshDir", tag.Directory.Of(dir)) +- _, done := event.Start(ctx, "cache.sharedModCache.refreshDir", label.Directory.Of(dir)) - defer done() - imports.ScanModuleCache(dir, cache, logf) - }) @@ -18975,7 +19041,7 @@ diff -urN a/gopls/internal/cache/keys.go b/gopls/internal/cache/keys.go diff -urN a/gopls/internal/cache/load.go b/gopls/internal/cache/load.go --- a/gopls/internal/cache/load.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/cache/load.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,790 +0,0 @@ +@@ -1,818 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -18996,13 +19062,13 @@ diff -urN a/gopls/internal/cache/load.go b/gopls/internal/cache/load.go - "golang.org/x/tools/go/packages" - "golang.org/x/tools/gopls/internal/cache/metadata" - "golang.org/x/tools/gopls/internal/file" +- "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/util/bug" - "golang.org/x/tools/gopls/internal/util/immutable" - "golang.org/x/tools/gopls/internal/util/pathutil" - "golang.org/x/tools/gopls/internal/util/slices" - "golang.org/x/tools/internal/event" -- "golang.org/x/tools/internal/event/tag" - "golang.org/x/tools/internal/gocommand" - "golang.org/x/tools/internal/packagesinternal" - "golang.org/x/tools/internal/xcontext" @@ -19021,12 +19087,16 @@ diff -urN a/gopls/internal/cache/load.go b/gopls/internal/cache/load.go -// -// If scopes contains a file scope there must be exactly one scope. -func (s *Snapshot) load(ctx context.Context, allowNetwork bool, scopes ...loadScope) (err error) { +- if ctx.Err() != nil { +- // Check context cancellation before incrementing id below: a load on a +- // cancelled context should be a no-op. +- return ctx.Err() +- } - id := atomic.AddUint64(&loadID, 1) - eventName := fmt.Sprintf("go/packages.Load #%d", id) // unique name for logging - - var query []string -- var containsDir bool // for logging -- var standalone bool // whether this is a load of a standalone file +- var standalone bool // whether this is a load of a standalone file - - // Keep track of module query -> module path so that we can later correlate query - // errors with errors. @@ -19081,19 +19151,17 @@ diff -urN a/gopls/internal/cache/load.go b/gopls/internal/cache/load.go - default: - panic(fmt.Sprintf("unknown scope type %T", scope)) - } -- switch scope.(type) { -- case viewLoadScope, moduleLoadScope: -- containsDir = true -- } - } - if len(query) == 0 { - return nil - } - sort.Strings(query) // for determinism - -- ctx, done := event.Start(ctx, "cache.snapshot.load", tag.Query.Of(query)) +- ctx, done := event.Start(ctx, "cache.snapshot.load", label.Query.Of(query)) - defer done() - +- startTime := time.Now() +- - flags := LoadWorkspace - if allowNetwork { - flags |= AllowNetwork @@ -19123,11 +19191,17 @@ diff -urN a/gopls/internal/cache/load.go b/gopls/internal/cache/load.go - } - - // This log message is sought for by TestReloadOnlyOnce. -- labels := append(s.Labels(), tag.Query.Of(query), tag.PackageCount.Of(len(pkgs))) -- if err != nil { -- event.Error(ctx, eventName, err, labels...) -- } else { -- event.Log(ctx, eventName, labels...) +- { +- lbls := append(s.Labels(), +- label.Query.Of(query), +- label.PackageCount.Of(len(pkgs)), +- label.Duration.Of(time.Since(startTime)), +- ) +- if err != nil { +- event.Error(ctx, eventName, err, lbls...) +- } else { +- event.Log(ctx, eventName, lbls...) +- } - } - - if standalone { @@ -19180,6 +19254,14 @@ diff -urN a/gopls/internal/cache/load.go b/gopls/internal/cache/load.go - filterFunc := s.view.filterFunc() - newMetadata := make(map[PackageID]*metadata.Package) - for _, pkg := range pkgs { +- if pkg.Module != nil && strings.Contains(pkg.Module.Path, "command-line-arguments") { +- // golang/go#61543: modules containing "command-line-arguments" cause +- // gopls to get all sorts of confused, because anything containing the +- // string "command-line-arguments" is treated as a script. And yes, this +- // happened in practice! (https://xkcd.com/327). Rather than try to work +- // around this very rare edge case, just fail loudly. +- return fmt.Errorf(`load failed: module name in %s contains "command-line-arguments", which is disallowed`, pkg.Module.GoMod) +- } - // The Go command returns synthetic list results for module queries that - // encountered module errors. - // @@ -19195,11 +19277,11 @@ diff -urN a/gopls/internal/cache/load.go b/gopls/internal/cache/load.go - continue - } - -- if !containsDir || s.Options().VerboseOutput { +- if s.Options().VerboseOutput { - event.Log(ctx, eventName, append( - s.Labels(), -- tag.Package.Of(pkg.ID), -- tag.Files.Of(pkg.CompiledGoFiles))...) +- label.Package.Of(pkg.ID), +- label.Files.Of(pkg.CompiledGoFiles))...) - } - - // Ignore packages with no sources, since we will never be able to @@ -19259,7 +19341,9 @@ diff -urN a/gopls/internal/cache/load.go b/gopls/internal/cache/load.go - } - } - -- event.Log(ctx, fmt.Sprintf("%s: updating metadata for %d packages", eventName, len(updates))) +- if s.Options().VerboseOutput { +- event.Log(ctx, fmt.Sprintf("%s: updating metadata for %d packages", eventName, len(updates))) +- } - - meta := s.meta.Update(updates) - workspacePackages := computeWorkspacePackagesLocked(ctx, s, meta) @@ -19323,6 +19407,11 @@ diff -urN a/gopls/internal/cache/load.go b/gopls/internal/cache/load.go - pkgPath := PackagePath(pkg.PkgPath) - id := PackageID(pkg.ID) - +- // debugging #60890 +- if pkg.PkgPath == "unsafe" && pkg.ID != "unsafe" { +- bug.Reportf("PackagePath \"unsafe\" with ID %q", pkg.ID) +- } +- - if metadata.IsCommandLineArguments(id) { - var f string // file to use as disambiguating suffix - if len(pkg.CompiledGoFiles) > 0 { @@ -19339,7 +19428,7 @@ diff -urN a/gopls/internal/cache/load.go b/gopls/internal/cache/load.go - // A file=empty.go query results in IgnoredFiles=[empty.go]. - f = pkg.IgnoredFiles[0] - } else { -- bug.Reportf("command-line-arguments package has neither CompiledGoFiles nor IgnoredFiles: %#v", "") //*pkg.Metadata) +- bug.Reportf("command-line-arguments package has neither CompiledGoFiles nor IgnoredFiles") - return nil - } - id = PackageID(pkg.ID + f) @@ -19374,6 +19463,11 @@ diff -urN a/gopls/internal/cache/load.go b/gopls/internal/cache/load.go - Standalone: standalone, - } - +- // debugging #60890 +- if mp.PkgPath == "unsafe" && mp.ID != "unsafe" { +- bug.Reportf("PackagePath \"unsafe\" with ID %q", mp.ID) +- } +- - updates[id] = mp - - for _, filename := range pkg.CompiledGoFiles { @@ -19520,7 +19614,7 @@ diff -urN a/gopls/internal/cache/load.go b/gopls/internal/cache/load.go - if err != nil { - // There are certain cases where the go command returns invalid - // positions, so we cannot panic or even bug.Reportf here. -- event.Error(ctx, "unable to compute positions for list errors", err, tag.Package.Of(string(mp.ID))) +- event.Error(ctx, "unable to compute positions for list errors", err, label.Package.Of(string(mp.ID))) - continue - } - diags = append(diags, pkgDiags...) @@ -19534,7 +19628,7 @@ diff -urN a/gopls/internal/cache/load.go b/gopls/internal/cache/load.go - if ctx.Err() == nil { - // TODO(rfindley): consider making this a bug.Reportf. depsErrors should - // not normally fail. -- event.Error(ctx, "unable to compute deps errors", err, tag.Package.Of(string(mp.ID))) +- event.Error(ctx, "unable to compute deps errors", err, label.Package.Of(string(mp.ID))) - } - } else { - diags = append(diags, depsDiags...) @@ -20493,7 +20587,7 @@ diff -urN a/gopls/internal/cache/metadata/metadata.go b/gopls/internal/cache/met -// to discard them before requesting type checking, or the products of -// type-checking such as the cross-reference index or method set index. -// --// MetadataForFile doesn't do this filtering itself becaused in some +-// MetadataForFile doesn't do this filtering itself because in some -// cases we need to make a reverse dependency query on the metadata -// graph, and it's important to include the rdeps of ITVs in that -// query. But the filtering of ITVs should be applied after that step, @@ -21109,10 +21203,10 @@ diff -urN a/gopls/internal/cache/mod.go b/gopls/internal/cache/mod.go - "golang.org/x/mod/modfile" - "golang.org/x/mod/module" - "golang.org/x/tools/gopls/internal/file" +- "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/protocol/command" - "golang.org/x/tools/internal/event" -- "golang.org/x/tools/internal/event/tag" - "golang.org/x/tools/internal/gocommand" - "golang.org/x/tools/internal/memoize" -) @@ -21164,7 +21258,7 @@ diff -urN a/gopls/internal/cache/mod.go b/gopls/internal/cache/mod.go -// parseModImpl parses the go.mod file whose name and contents are in fh. -// It may return partial results and an error. -func parseModImpl(ctx context.Context, fh file.Handle) (*ParsedModule, error) { -- _, done := event.Start(ctx, "cache.ParseMod", tag.URI.Of(fh.URI())) +- _, done := event.Start(ctx, "cache.ParseMod", label.URI.Of(fh.URI())) - defer done() - - contents, err := fh.Content() @@ -21249,7 +21343,7 @@ diff -urN a/gopls/internal/cache/mod.go b/gopls/internal/cache/mod.go - -// parseWorkImpl parses a go.work file. It may return partial results and an error. -func parseWorkImpl(ctx context.Context, fh file.Handle) (*ParsedWorkFile, error) { -- _, done := event.Start(ctx, "cache.ParseWork", tag.URI.Of(fh.URI())) +- _, done := event.Start(ctx, "cache.ParseWork", label.URI.Of(fh.URI())) - defer done() - - content, err := fh.Content() @@ -21359,7 +21453,7 @@ diff -urN a/gopls/internal/cache/mod.go b/gopls/internal/cache/mod.go - -// modWhyImpl returns the result of "go mod why -m" on the specified go.mod file. -func modWhyImpl(ctx context.Context, snapshot *Snapshot, fh file.Handle) (map[string]string, error) { -- ctx, done := event.Start(ctx, "cache.ModWhy", tag.URI.Of(fh.URI())) +- ctx, done := event.Start(ctx, "cache.ModWhy", label.URI.Of(fh.URI())) - defer done() - - pm, err := snapshot.ParseMod(ctx, fh) @@ -21647,11 +21741,11 @@ diff -urN a/gopls/internal/cache/mod_tidy.go b/gopls/internal/cache/mod_tidy.go - "golang.org/x/mod/modfile" - "golang.org/x/tools/gopls/internal/cache/parsego" - "golang.org/x/tools/gopls/internal/file" +- "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/protocol/command" - "golang.org/x/tools/internal/diff" - "golang.org/x/tools/internal/event" -- "golang.org/x/tools/internal/event/tag" - "golang.org/x/tools/internal/gocommand" - "golang.org/x/tools/internal/memoize" -) @@ -21728,7 +21822,7 @@ diff -urN a/gopls/internal/cache/mod_tidy.go b/gopls/internal/cache/mod_tidy.go - -// modTidyImpl runs "go mod tidy" on a go.mod file. -func modTidyImpl(ctx context.Context, snapshot *Snapshot, filename string, pm *ParsedModule) (*TidiedModule, error) { -- ctx, done := event.Start(ctx, "cache.ModTidy", tag.URI.Of(filename)) +- ctx, done := event.Start(ctx, "cache.ModTidy", label.File.Of(filename)) - defer done() - - inv := &gocommand.Invocation{ @@ -23668,12 +23762,12 @@ diff -urN a/gopls/internal/cache/parsego/parse.go b/gopls/internal/cache/parsego - "go/token" - "reflect" - +- "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/util/astutil" - "golang.org/x/tools/gopls/internal/util/safetoken" - "golang.org/x/tools/internal/diff" - "golang.org/x/tools/internal/event" -- "golang.org/x/tools/internal/event/tag" -) - -// Common parse modes; these should be reused wherever possible to increase @@ -23696,7 +23790,7 @@ diff -urN a/gopls/internal/cache/parsego/parse.go b/gopls/internal/cache/parsego - if purgeFuncBodies { - src = astutil.PurgeFuncBodies(src) - } -- ctx, done := event.Start(ctx, "cache.ParseGoSrc", tag.File.Of(uri.Path())) +- ctx, done := event.Start(ctx, "cache.ParseGoSrc", label.File.Of(uri.Path())) - defer done() - - file, err := parser.ParseFile(fset, uri.Path(), src, mode) @@ -23738,7 +23832,7 @@ diff -urN a/gopls/internal/cache/parsego/parse.go b/gopls/internal/cache/parsego - // of the last changes we made to aid in debugging. - if i == 9 { - unified := diff.Unified("before", "after", string(src), string(newSrc)) -- event.Log(ctx, fmt.Sprintf("fixSrc loop - last diff:\n%v", unified), tag.File.Of(tok.Name())) +- event.Log(ctx, fmt.Sprintf("fixSrc loop - last diff:\n%v", unified), label.File.Of(tok.Name())) - } - - newFile, newErr := parser.ParseFile(fset, uri.Path(), newSrc, mode) @@ -25008,7 +25102,7 @@ diff -urN a/gopls/internal/cache/port_test.go b/gopls/internal/cache/port_test.g diff -urN a/gopls/internal/cache/session.go b/gopls/internal/cache/session.go --- a/gopls/internal/cache/session.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/cache/session.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,1182 +0,0 @@ +@@ -1,1207 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -25031,12 +25125,14 @@ diff -urN a/gopls/internal/cache/session.go b/gopls/internal/cache/session.go - "golang.org/x/tools/gopls/internal/cache/metadata" - "golang.org/x/tools/gopls/internal/cache/typerefs" - "golang.org/x/tools/gopls/internal/file" +- "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/util/bug" - "golang.org/x/tools/gopls/internal/util/persistent" - "golang.org/x/tools/gopls/internal/util/slices" - "golang.org/x/tools/gopls/internal/vulncheck" - "golang.org/x/tools/internal/event" +- "golang.org/x/tools/internal/event/keys" - "golang.org/x/tools/internal/gocommand" - "golang.org/x/tools/internal/imports" - "golang.org/x/tools/internal/memoize" @@ -25274,7 +25370,15 @@ diff -urN a/gopls/internal/cache/session.go b/gopls/internal/cache/session.go - } - - // Record the environment of the newly created view in the log. -- event.Log(ctx, viewEnv(v)) +- event.Log(ctx, fmt.Sprintf("Created View (#%s)", v.id), +- label.Directory.Of(v.folder.Dir.Path()), +- viewTypeKey.Of(v.typ.String()), +- rootDirKey.Of(string(v.root)), +- goVersionKey.Of(strings.TrimRight(v.folder.Env.GoVersionOutput, "\n")), +- buildFlagsKey.Of(fmt.Sprint(v.folder.Options.BuildFlags)), +- envKey.Of(fmt.Sprintf("%+v", v.folder.Env)), +- envOverlayKey.Of(v.EnvOverlay()), +- ) - - // Initialize the view without blocking. - initCtx, initCancel := context.WithCancel(xcontext.Detach(ctx)) @@ -25292,6 +25396,16 @@ diff -urN a/gopls/internal/cache/session.go b/gopls/internal/cache/session.go - return v, snapshot, snapshot.Acquire() -} - +-// These keys are used to log view metadata in createView. +-var ( +- viewTypeKey = keys.NewString("view_type", "") +- rootDirKey = keys.NewString("root_dir", "") +- goVersionKey = keys.NewString("go_version", "") +- buildFlagsKey = keys.New("build_flags", "") +- envKey = keys.New("env", "") +- envOverlayKey = keys.New("env_overlay", "") +-) +- -// RemoveView removes from the session the view rooted at the specified directory. -// It reports whether a view of that directory was removed. -func (s *Session) RemoveView(dir protocol.DocumentURI) bool { @@ -25380,11 +25494,11 @@ diff -urN a/gopls/internal/cache/session.go b/gopls/internal/cache/session.go - if err != nil { - continue // view was shut down - } -- _ = snapshot.awaitLoaded(ctx) // ignore error -- g := snapshot.MetadataGraph() - // We don't check the error from awaitLoaded, because a load failure (that - // doesn't result from context cancelation) should not prevent us from - // continuing to search for the best view. +- _ = snapshot.awaitLoaded(ctx) +- g := snapshot.MetadataGraph() - if ctx.Err() != nil { - release() - return nil, nil, ctx.Err() @@ -26132,6 +26246,11 @@ diff -urN a/gopls/internal/cache/session.go b/gopls/internal/cache/session.go -// -// The caller must not mutate the result. -func (s *Session) OrphanedFileDiagnostics(ctx context.Context) (map[protocol.DocumentURI][]*Diagnostic, error) { +- if err := ctx.Err(); err != nil { +- // Avoid collecting diagnostics if the context is cancelled. +- // (Previously, it was possible to get all the way to packages.Load on a cancelled context) +- return nil, err +- } - // Note: diagnostics holds a slice for consistency with other diagnostic - // funcs. - diagnostics := make(map[protocol.DocumentURI][]*Diagnostic) @@ -26548,7 +26667,7 @@ diff -urN a/gopls/internal/cache/session_test.go b/gopls/internal/cache/session_ - Dir: toURI(f.dir), - Name: path.Base(f.dir), - Options: opts, -- Env: env, +- Env: *env, - }) - } - @@ -26641,6 +26760,7 @@ diff -urN a/gopls/internal/cache/snapshot.go b/gopls/internal/cache/snapshot.go - "golang.org/x/tools/gopls/internal/cache/xrefs" - "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/filecache" +- label1 "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/protocol/command" - "golang.org/x/tools/gopls/internal/settings" @@ -26653,7 +26773,6 @@ diff -urN a/gopls/internal/cache/snapshot.go b/gopls/internal/cache/snapshot.go - "golang.org/x/tools/gopls/internal/vulncheck" - "golang.org/x/tools/internal/event" - "golang.org/x/tools/internal/event/label" -- "golang.org/x/tools/internal/event/tag" - "golang.org/x/tools/internal/gocommand" - "golang.org/x/tools/internal/memoize" - "golang.org/x/tools/internal/packagesinternal" @@ -26875,7 +26994,11 @@ diff -urN a/gopls/internal/cache/snapshot.go b/gopls/internal/cache/snapshot.go -// SnapshotLabels returns a new slice of labels that should be used for events -// related to a snapshot. -func (s *Snapshot) Labels() []label.Label { -- return []label.Label{tag.Snapshot.Of(s.SequenceID()), tag.Directory.Of(s.Folder())} +- return []label.Label{ +- label1.ViewID.Of(s.view.id), +- label1.Snapshot.Of(s.SequenceID()), +- label1.Directory.Of(s.Folder().Path()), +- } -} - -// Folder returns the folder at the base of this snapshot. @@ -27108,7 +27231,6 @@ diff -urN a/gopls/internal/cache/snapshot.go b/gopls/internal/cache/snapshot.go -// TODO(adonovan): simplify cleanup mechanism. It's hard to see, but -// it used only after call to tempModFile. -func (s *Snapshot) goCommandInvocation(ctx context.Context, flags InvocationFlags, inv *gocommand.Invocation) (tmpURI protocol.DocumentURI, updatedInv *gocommand.Invocation, cleanup func(), err error) { -- allowModfileModificationOption := s.Options().AllowModfileModifications - allowNetworkOption := s.Options().AllowImplicitNetworkAccess - - // TODO(rfindley): it's not clear that this is doing the right thing. @@ -27161,17 +27283,10 @@ diff -urN a/gopls/internal/cache/snapshot.go b/gopls/internal/cache/snapshot.go - // (As noted in various TODOs throughout this function, this is very - // confusing and not obviously correct, but tests pass and we will eventually - // rewrite this entire function.) -- if inv.ModFlag == "" { -- switch mode { -- case LoadWorkspace, Normal: -- if allowModfileModificationOption { -- inv.ModFlag = mutableModFlag -- } -- case WriteTemporaryModFile: -- inv.ModFlag = mutableModFlag -- // -mod must be readonly when using go.work files - see issue #48941 -- inv.Env = append(inv.Env, "GOWORK=off") -- } +- if inv.ModFlag == "" && mode == WriteTemporaryModFile { +- inv.ModFlag = mutableModFlag +- // -mod must be readonly when using go.work files - see issue #48941 +- inv.Env = append(inv.Env, "GOWORK=off") - } - - // TODO(rfindley): if inv.ModFlag was already set to "mod", we may not have @@ -27987,6 +28102,10 @@ diff -urN a/gopls/internal/cache/snapshot.go b/gopls/internal/cache/snapshot.go - -// reloadWorkspace reloads the metadata for all invalidated workspace packages. -func (s *Snapshot) reloadWorkspace(ctx context.Context) { +- if ctx.Err() != nil { +- return +- } +- - var scopes []loadScope - var seen map[PackagePath]bool - s.mu.Lock() @@ -31522,7 +31641,7 @@ diff -urN a/gopls/internal/cache/typerefs/refs_test.go b/gopls/internal/cache/ty diff -urN a/gopls/internal/cache/view.go b/gopls/internal/cache/view.go --- a/gopls/internal/cache/view.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/cache/view.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,1299 +0,0 @@ +@@ -1,1272 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -31535,7 +31654,6 @@ diff -urN a/gopls/internal/cache/view.go b/gopls/internal/cache/view.go -package cache - -import ( -- "bytes" - "context" - "encoding/json" - "errors" @@ -31576,7 +31694,7 @@ diff -urN a/gopls/internal/cache/view.go b/gopls/internal/cache/view.go - Dir protocol.DocumentURI - Name string // decorative name for UI; not necessarily unique - Options *settings.Options -- Env *GoEnv +- Env GoEnv -} - -// GoEnv holds the environment variables and data from the Go command that is @@ -31827,15 +31945,15 @@ diff -urN a/gopls/internal/cache/view.go b/gopls/internal/cache/view.go -func (t ViewType) String() string { - switch t { - case GoPackagesDriverView: -- return "GoPackagesDriverView" +- return "GoPackagesDriver" - case GOPATHView: -- return "GOPATHView" +- return "GOPATH" - case GoModView: -- return "GoModView" +- return "GoMod" - case GoWorkView: -- return "GoWorkView" +- return "GoWork" - case AdHocView: -- return "AdHocView" +- return "AdHoc" - default: - return "Unknown" - } @@ -31932,32 +32050,6 @@ diff -urN a/gopls/internal/cache/view.go b/gopls/internal/cache/view.go - return nil -} - --// viewEnv returns a string describing the environment of a newly created view. --// --// It must not be called concurrently with any other view methods. --// TODO(rfindley): rethink this function, or inline sole call. --func viewEnv(v *View) string { -- var buf bytes.Buffer -- fmt.Fprintf(&buf, `go info for %v --(view type %v) --(root dir %s) --(go version %s) --(build flags: %v) --(go env: %+v) --(env overlay: %v) --`, -- v.folder.Dir.Path(), -- v.typ, -- v.root.Path(), -- strings.TrimRight(v.folder.Env.GoVersionOutput, "\n"), -- v.folder.Options.BuildFlags, -- *v.folder.Env, -- v.envOverlay, -- ) -- -- return buf.String() --} -- -// RunProcessEnvFunc runs fn with the process env for this snapshot's view. -// Note: the process env contains cached module and filesystem state. -func (s *Snapshot) RunProcessEnvFunc(ctx context.Context, fn func(context.Context, *imports.Options) error) error { @@ -33508,7 +33600,7 @@ diff -urN a/gopls/internal/cmd/capabilities_test.go b/gopls/internal/cmd/capabil - } - defer os.RemoveAll(tmpDir) - -- app := New(nil) +- app := New() - - params := &protocol.ParamInitialize{} - params.RootURI = protocol.URIFromPath(tmpDir) @@ -33645,7 +33737,7 @@ diff -urN a/gopls/internal/cmd/capabilities_test.go b/gopls/internal/cmd/capabil diff -urN a/gopls/internal/cmd/check.go b/gopls/internal/cmd/check.go --- a/gopls/internal/cmd/check.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/cmd/check.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,73 +0,0 @@ +@@ -1,110 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -33658,6 +33750,8 @@ diff -urN a/gopls/internal/cmd/check.go b/gopls/internal/cmd/check.go - "fmt" - - "golang.org/x/tools/gopls/internal/protocol" +- "golang.org/x/tools/gopls/internal/settings" +- "golang.org/x/tools/gopls/internal/util/slices" -) - -// check implements the check verb for gopls. @@ -33682,17 +33776,32 @@ diff -urN a/gopls/internal/cmd/check.go b/gopls/internal/cmd/check.go -// results to stdout. -func (c *check) Run(ctx context.Context, args ...string) error { - if len(args) == 0 { -- // no files, so no results - return nil - } -- checking := map[protocol.DocumentURI]*cmdFile{} -- var uris []protocol.DocumentURI -- // now we ready to kick things off +- +- // TODO(adonovan): formally, we are required to set this +- // option if we want RelatedInformation, but it appears to +- // have no effect on the server, even though the default is +- // false. Investigate. +- origOptions := c.app.options +- c.app.options = func(opts *settings.Options) { +- if origOptions != nil { +- origOptions(opts) +- } +- opts.RelatedInformationSupported = true +- } +- - conn, err := c.app.connect(ctx, nil) - if err != nil { - return err - } - defer conn.terminate(ctx) +- +- // Open and diagnose the requested files. +- var ( +- uris []protocol.DocumentURI +- checking = make(map[protocol.DocumentURI]*cmdFile) +- ) - for _, arg := range args { - uri := protocol.URIFromPath(arg) - uris = append(uris, uri) @@ -33705,16 +33814,36 @@ diff -urN a/gopls/internal/cmd/check.go b/gopls/internal/cmd/check.go - if err := conn.diagnoseFiles(ctx, uris); err != nil { - return err - } -- conn.client.filesMu.Lock() -- defer conn.client.filesMu.Unlock() +- +- // print prints a single element of a diagnostic. +- print := func(uri protocol.DocumentURI, rng protocol.Range, message string) error { +- file, err := conn.openFile(ctx, uri) +- if err != nil { +- return err +- } +- spn, err := file.rangeSpan(rng) +- if err != nil { +- return fmt.Errorf("could not convert position %v for %q", rng, message) +- } +- fmt.Printf("%v: %v\n", spn, message) +- return nil +- } - - for _, file := range checking { -- for _, d := range file.diagnostics { -- spn, err := file.rangeSpan(d.Range) -- if err != nil { -- return fmt.Errorf("Could not convert position %v for %q", d.Range, d.Message) +- file.diagnosticsMu.Lock() +- diags := slices.Clone(file.diagnostics) +- file.diagnosticsMu.Unlock() +- +- for _, diag := range diags { +- if err := print(file.uri, diag.Range, diag.Message); err != nil { +- return err +- } +- for _, rel := range diag.RelatedInformation { +- if err := print(rel.Location.URI, rel.Location.Range, "- "+rel.Message); err != nil { +- return err +- } - } -- fmt.Printf("%v: %v\n", spn, d.Message) +- - } - } - return nil @@ -33722,7 +33851,7 @@ diff -urN a/gopls/internal/cmd/check.go b/gopls/internal/cmd/check.go diff -urN a/gopls/internal/cmd/cmd.go b/gopls/internal/cmd/cmd.go --- a/gopls/internal/cmd/cmd.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/cmd/cmd.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,843 +0,0 @@ +@@ -1,845 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -33820,9 +33949,8 @@ diff -urN a/gopls/internal/cmd/cmd.go b/gopls/internal/cmd/cmd.go -} - -// New returns a new Application ready to run. --func New(options func(*settings.Options)) *Application { +-func New() *Application { - app := &Application{ -- options: options, - OCAgent: "off", //TODO: Remove this line to default the exporter to on - - Serve: Serve{ @@ -34124,15 +34252,16 @@ diff -urN a/gopls/internal/cmd/cmd.go b/gopls/internal/cmd/cmd.go - app *Application - onProgress func(*protocol.ProgressParams) - -- filesMu sync.Mutex // guards files map and each cmdFile.diagnostics +- filesMu sync.Mutex // guards files map - files map[protocol.DocumentURI]*cmdFile -} - -type cmdFile struct { -- uri protocol.DocumentURI -- mapper *protocol.Mapper -- err error -- diagnostics []protocol.Diagnostic +- uri protocol.DocumentURI +- mapper *protocol.Mapper +- err error +- diagnosticsMu sync.Mutex +- diagnostics []protocol.Diagnostic -} - -func newClient(app *Application, onProgress func(*protocol.ProgressParams)) *cmdClient { @@ -34320,9 +34449,11 @@ diff -urN a/gopls/internal/cmd/cmd.go b/gopls/internal/cmd/cmd.go - } - - c.filesMu.Lock() -- defer c.filesMu.Unlock() -- - file := c.getFile(p.URI) +- c.filesMu.Unlock() +- +- file.diagnosticsMu.Lock() +- defer file.diagnosticsMu.Unlock() - file.diagnostics = append(file.diagnostics, p.Diagnostics...) - - // Perform a crude in-place deduplication. @@ -34569,7 +34700,7 @@ diff -urN a/gopls/internal/cmd/cmd.go b/gopls/internal/cmd/cmd.go diff -urN a/gopls/internal/cmd/codelens.go b/gopls/internal/cmd/codelens.go --- a/gopls/internal/cmd/codelens.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/cmd/codelens.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,138 +0,0 @@ +@@ -1,140 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -34646,7 +34777,9 @@ diff -urN a/gopls/internal/cmd/codelens.go b/gopls/internal/cmd/codelens.go - // See golang.LensFuncs(). - origOptions := r.app.options - r.app.options = func(opts *settings.Options) { -- origOptions(opts) +- if origOptions != nil { +- origOptions(opts) +- } - if opts.Codelenses == nil { - opts.Codelenses = make(map[string]bool) - } @@ -35200,7 +35333,7 @@ diff -urN a/gopls/internal/cmd/help_test.go b/gopls/internal/cmd/help_test.go - -func TestHelpFiles(t *testing.T) { - testenv.NeedsGoBuild(t) // This is a lie. We actually need the source code. -- app := cmd.New(nil) +- app := cmd.New() - ctx := context.Background() - for _, page := range append(app.Commands(), app) { - t.Run(page.Name(), func(t *testing.T) { @@ -35233,7 +35366,7 @@ diff -urN a/gopls/internal/cmd/help_test.go b/gopls/internal/cmd/help_test.go - -func TestVerboseHelp(t *testing.T) { - testenv.NeedsGoBuild(t) // This is a lie. We actually need the source code. -- app := cmd.New(nil) +- app := cmd.New() - ctx := context.Background() - var buf bytes.Buffer - s := flag.NewFlagSet(appName, flag.ContinueOnError) @@ -35540,6 +35673,7 @@ diff -urN a/gopls/internal/cmd/info.go b/gopls/internal/cmd/info.go - - "golang.org/x/tools/gopls/internal/debug" - "golang.org/x/tools/gopls/internal/filecache" +- licensespkg "golang.org/x/tools/gopls/internal/licenses" - "golang.org/x/tools/gopls/internal/settings" - "golang.org/x/tools/gopls/internal/util/browser" - goplsbug "golang.org/x/tools/gopls/internal/util/bug" @@ -35822,12 +35956,11 @@ diff -urN a/gopls/internal/cmd/info.go b/gopls/internal/cmd/info.go -` - -func (l *licenses) Run(ctx context.Context, args ...string) error { -- opts := settings.DefaultOptions(l.app.options) - txt := licensePreamble -- if opts.LicensesText == "" { +- if licensespkg.Text == "" { - txt += "(development gopls, license information not available)" - } else { -- txt += opts.LicensesText +- txt += licensespkg.Text - } - fmt.Fprint(os.Stdout, txt) - return nil @@ -35835,7 +35968,7 @@ diff -urN a/gopls/internal/cmd/info.go b/gopls/internal/cmd/info.go diff -urN a/gopls/internal/cmd/integration_test.go b/gopls/internal/cmd/integration_test.go --- a/gopls/internal/cmd/integration_test.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/cmd/integration_test.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,1187 +0,0 @@ +@@ -1,1200 +0,0 @@ -// Copyright 2023 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -35878,7 +36011,6 @@ diff -urN a/gopls/internal/cmd/integration_test.go b/gopls/internal/cmd/integrat - - "golang.org/x/tools/gopls/internal/cmd" - "golang.org/x/tools/gopls/internal/debug" -- "golang.org/x/tools/gopls/internal/hooks" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/util/bug" - "golang.org/x/tools/gopls/internal/version" @@ -35941,6 +36073,12 @@ diff -urN a/gopls/internal/cmd/integration_test.go b/gopls/internal/cmd/integrat -package a -import "fmt" -var _ = fmt.Sprintf("%d", "123") +--- c/c.go -- +-package c +-var C int +--- c/c2.go -- +-package c +-var C int -`) - - // no files @@ -35966,6 +36104,14 @@ diff -urN a/gopls/internal/cmd/integration_test.go b/gopls/internal/cmd/integrat - res.checkStdout(`a.go:.* fmt.Sprintf format %s has arg 123 of wrong type int`) - res.checkStdout(`b.go:.* fmt.Sprintf format %d has arg "123" of wrong type string`) - } +- +- // diagnostic with related information spanning files +- { +- res := gopls(t, tree, "check", "./c/c2.go") +- res.checkExit(true) +- res.checkStdout(`c2.go:2:5-6: C redeclared in this block`) +- res.checkStdout(`c.go:2:5-6: - other declaration of C`) +- } -} - -// TestCallHierarchy tests the 'call_hierarchy' subcommand (../call_hierarchy.go). @@ -36884,7 +37030,7 @@ diff -urN a/gopls/internal/cmd/integration_test.go b/gopls/internal/cmd/integrat - version.VersionOverride = v - } - -- tool.Main(context.Background(), cmd.New(hooks.Options), os.Args[1:]) +- tool.Main(context.Background(), cmd.New(), os.Args[1:]) -} - -// writeTree extracts a txtar archive into a new directory and returns its path. @@ -37639,7 +37785,7 @@ diff -urN a/gopls/internal/cmd/rename.go b/gopls/internal/cmd/rename.go diff -urN a/gopls/internal/cmd/semantictokens.go b/gopls/internal/cmd/semantictokens.go --- a/gopls/internal/cmd/semantictokens.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/cmd/semantictokens.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,194 +0,0 @@ +@@ -1,196 +0,0 @@ -// Copyright 2020 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -37708,7 +37854,9 @@ diff -urN a/gopls/internal/cmd/semantictokens.go b/gopls/internal/cmd/semanticto - // perhaps simpler if app had just had a FlagSet member - origOptions := c.app.options - c.app.options = func(opts *settings.Options) { -- origOptions(opts) +- if origOptions != nil { +- origOptions(opts) +- } - opts.SemanticTokens = true - } - conn, err := c.app.connect(ctx, nil) @@ -40069,9 +40217,9 @@ diff -urN a/gopls/internal/debug/log/log.go b/gopls/internal/debug/log/log.go - "context" - "fmt" - +- label1 "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/internal/event" - "golang.org/x/tools/internal/event/label" -- "golang.org/x/tools/internal/event/tag" -) - -// Level parameterizes log severity. @@ -40088,7 +40236,7 @@ diff -urN a/gopls/internal/debug/log/log.go b/gopls/internal/debug/log/log.go - -// Log exports a log event labeled with level l. -func (l Level) Log(ctx context.Context, msg string) { -- event.Log(ctx, msg, tag.Level.Of(int(l))) +- event.Log(ctx, msg, label1.Level.Of(int(l))) -} - -// Logf formats and exports a log event labeled with level l. @@ -40098,7 +40246,7 @@ diff -urN a/gopls/internal/debug/log/log.go b/gopls/internal/debug/log/log.go - -// LabeledLevel extracts the labeled log l -func LabeledLevel(lm label.Map) Level { -- return Level(tag.Level.Get(lm)) +- return Level(label1.Level.Get(lm)) -} diff -urN a/gopls/internal/debug/metrics.go b/gopls/internal/debug/metrics.go --- a/gopls/internal/debug/metrics.go 2000-01-01 00:00:00.000000000 -0000 @@ -40113,7 +40261,7 @@ diff -urN a/gopls/internal/debug/metrics.go b/gopls/internal/debug/metrics.go -import ( - "golang.org/x/tools/internal/event/export/metric" - "golang.org/x/tools/internal/event/label" -- "golang.org/x/tools/internal/event/tag" +- "golang.org/x/tools/internal/jsonrpc2" -) - -var ( @@ -40124,43 +40272,43 @@ diff -urN a/gopls/internal/debug/metrics.go b/gopls/internal/debug/metrics.go - receivedBytes = metric.HistogramInt64{ - Name: "received_bytes", - Description: "Distribution of received bytes, by method.", -- Keys: []label.Key{tag.RPCDirection, tag.Method}, +- Keys: []label.Key{jsonrpc2.RPCDirection, jsonrpc2.Method}, - Buckets: bytesDistribution, - } - - sentBytes = metric.HistogramInt64{ - Name: "sent_bytes", - Description: "Distribution of sent bytes, by method.", -- Keys: []label.Key{tag.RPCDirection, tag.Method}, +- Keys: []label.Key{jsonrpc2.RPCDirection, jsonrpc2.Method}, - Buckets: bytesDistribution, - } - - latency = metric.HistogramFloat64{ - Name: "latency", - Description: "Distribution of latency in milliseconds, by method.", -- Keys: []label.Key{tag.RPCDirection, tag.Method}, +- Keys: []label.Key{jsonrpc2.RPCDirection, jsonrpc2.Method}, - Buckets: millisecondsDistribution, - } - - started = metric.Scalar{ - Name: "started", - Description: "Count of RPCs started by method.", -- Keys: []label.Key{tag.RPCDirection, tag.Method}, +- Keys: []label.Key{jsonrpc2.RPCDirection, jsonrpc2.Method}, - } - - completed = metric.Scalar{ - Name: "completed", - Description: "Count of RPCs completed by method and status.", -- Keys: []label.Key{tag.RPCDirection, tag.Method, tag.StatusCode}, +- Keys: []label.Key{jsonrpc2.RPCDirection, jsonrpc2.Method, jsonrpc2.StatusCode}, - } -) - -func registerMetrics(m *metric.Config) { -- receivedBytes.Record(m, tag.ReceivedBytes) -- sentBytes.Record(m, tag.SentBytes) -- latency.Record(m, tag.Latency) -- started.Count(m, tag.Started) -- completed.Count(m, tag.Latency) +- receivedBytes.Record(m, jsonrpc2.ReceivedBytes) +- sentBytes.Record(m, jsonrpc2.SentBytes) +- latency.Record(m, jsonrpc2.Latency) +- started.Count(m, jsonrpc2.Started) +- completed.Count(m, jsonrpc2.Latency) -} diff -urN a/gopls/internal/debug/rpc.go b/gopls/internal/debug/rpc.go --- a/gopls/internal/debug/rpc.go 2000-01-01 00:00:00.000000000 -0000 @@ -40185,7 +40333,7 @@ diff -urN a/gopls/internal/debug/rpc.go b/gopls/internal/debug/rpc.go - "golang.org/x/tools/internal/event/core" - "golang.org/x/tools/internal/event/export" - "golang.org/x/tools/internal/event/label" -- "golang.org/x/tools/internal/event/tag" +- "golang.org/x/tools/internal/jsonrpc2" -) - -var RPCTmpl = template.Must(template.Must(BaseTemplate.Clone()).Parse(` @@ -40261,8 +40409,8 @@ diff -urN a/gopls/internal/debug/rpc.go b/gopls/internal/debug/rpc.go - endRPC(span, stats) - } - case event.IsMetric(ev): -- sent := byteUnits(tag.SentBytes.Get(lm)) -- rec := byteUnits(tag.ReceivedBytes.Get(lm)) +- sent := byteUnits(jsonrpc2.SentBytes.Get(lm)) +- rec := byteUnits(jsonrpc2.ReceivedBytes.Get(lm)) - if sent != 0 || rec != 0 { - if _, stats := r.getRPCSpan(ctx); stats != nil { - stats.Sent += sent @@ -40332,12 +40480,12 @@ diff -urN a/gopls/internal/debug/rpc.go b/gopls/internal/debug/rpc.go -} - -func (r *Rpcs) getRPCStats(lm label.Map) *rpcStats { -- method := tag.Method.Get(lm) +- method := jsonrpc2.Method.Get(lm) - if method == "" { - return nil - } - set := &r.Inbound -- if tag.RPCDirection.Get(lm) != tag.Inbound { +- if jsonrpc2.RPCDirection.Get(lm) != jsonrpc2.Inbound { - set = &r.Outbound - } - // get the record for this method @@ -40370,7 +40518,7 @@ diff -urN a/gopls/internal/debug/rpc.go b/gopls/internal/debug/rpc.go - -func getStatusCode(span *export.Span) string { - for _, ev := range span.Events() { -- if status := tag.StatusCode.Get(ev); status != "" { +- if status := jsonrpc2.StatusCode.Get(ev); status != "" { - return status - } - } @@ -40437,6 +40585,7 @@ diff -urN a/gopls/internal/debug/serve.go b/gopls/internal/debug/serve.go - - "golang.org/x/tools/gopls/internal/cache" - "golang.org/x/tools/gopls/internal/debug/log" +- label1 "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/util/bug" - "golang.org/x/tools/internal/event" @@ -40447,7 +40596,6 @@ diff -urN a/gopls/internal/debug/serve.go b/gopls/internal/debug/serve.go - "golang.org/x/tools/internal/event/export/prometheus" - "golang.org/x/tools/internal/event/keys" - "golang.org/x/tools/internal/event/label" -- "golang.org/x/tools/internal/event/tag" -) - -type contextKeyType int @@ -40851,7 +40999,7 @@ diff -urN a/gopls/internal/debug/serve.go b/gopls/internal/debug/serve.go - if strings.HasSuffix(i.debugAddress, ":0") { - stdlog.Printf("debug server listening at http://localhost:%d", port) - } -- event.Log(ctx, "Debug serving", tag.Port.Of(port)) +- event.Log(ctx, "Debug serving", label1.Port.Of(port)) - go func() { - mux := http.NewServeMux() - mux.HandleFunc("/", render(MainTmpl, func(*http.Request) interface{} { return i })) @@ -40972,27 +41120,27 @@ diff -urN a/gopls/internal/debug/serve.go b/gopls/internal/debug/serve.go - if s := cache.KeyCreateSession.Get(ev); s != nil { - i.State.addClient(s) - } -- if sid := tag.NewServer.Get(ev); sid != "" { +- if sid := label1.NewServer.Get(ev); sid != "" { - i.State.updateServer(&Server{ - ID: sid, -- Logfile: tag.Logfile.Get(ev), -- DebugAddress: tag.DebugAddress.Get(ev), -- GoplsPath: tag.GoplsPath.Get(ev), -- ClientID: tag.ClientID.Get(ev), +- Logfile: label1.Logfile.Get(ev), +- DebugAddress: label1.DebugAddress.Get(ev), +- GoplsPath: label1.GoplsPath.Get(ev), +- ClientID: label1.ClientID.Get(ev), - }) - } - if s := cache.KeyShutdownSession.Get(ev); s != nil { - i.State.dropClient(s) - } -- if sid := tag.EndServer.Get(ev); sid != "" { +- if sid := label1.EndServer.Get(ev); sid != "" { - i.State.dropServer(sid) - } - if s := cache.KeyUpdateSession.Get(ev); s != nil { - if c := i.State.Client(s.ID()); c != nil { -- c.DebugAddress = tag.DebugAddress.Get(ev) -- c.Logfile = tag.Logfile.Get(ev) -- c.ServerID = tag.ServerID.Get(ev) -- c.GoplsPath = tag.GoplsPath.Get(ev) +- c.DebugAddress = label1.DebugAddress.Get(ev) +- c.Logfile = label1.Logfile.Get(ev) +- c.ServerID = label1.ServerID.Get(ev) +- c.GoplsPath = label1.GoplsPath.Get(ev) - } - } - } @@ -42896,7 +43044,7 @@ diff -urN a/gopls/internal/golang/add_import.go b/gopls/internal/golang/add_impo diff -urN a/gopls/internal/golang/call_hierarchy.go b/gopls/internal/golang/call_hierarchy.go --- a/gopls/internal/golang/call_hierarchy.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/golang/call_hierarchy.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,313 +0,0 @@ +@@ -1,312 +0,0 @@ -// Copyright 2020 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -42920,7 +43068,6 @@ diff -urN a/gopls/internal/golang/call_hierarchy.go b/gopls/internal/golang/call - "golang.org/x/tools/gopls/internal/util/bug" - "golang.org/x/tools/gopls/internal/util/safetoken" - "golang.org/x/tools/internal/event" -- "golang.org/x/tools/internal/event/tag" -) - -// PrepareCallHierarchy returns an array of CallHierarchyItem for a file and the position within the file. @@ -42982,7 +43129,7 @@ diff -urN a/gopls/internal/golang/call_hierarchy.go b/gopls/internal/golang/call - for _, ref := range refs { - callItem, err := enclosingNodeCallItem(ctx, snapshot, ref.pkgPath, ref.location) - if err != nil { -- event.Error(ctx, "error getting enclosing node", err, tag.Method.Of(string(ref.pkgPath))) +- event.Error(ctx, fmt.Sprintf("error getting enclosing node for %q", ref.pkgPath), err) - continue - } - loc := protocol.Location{ @@ -43922,7 +44069,7 @@ diff -urN a/gopls/internal/golang/change_signature.go b/gopls/internal/golang/ch diff -urN a/gopls/internal/golang/codeaction.go b/gopls/internal/golang/codeaction.go --- a/gopls/internal/golang/codeaction.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/golang/codeaction.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,517 +0,0 @@ +@@ -1,521 +0,0 @@ -// Copyright 2024 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -43942,13 +44089,13 @@ diff -urN a/gopls/internal/golang/codeaction.go b/gopls/internal/golang/codeacti - "golang.org/x/tools/gopls/internal/cache" - "golang.org/x/tools/gopls/internal/cache/parsego" - "golang.org/x/tools/gopls/internal/file" +- "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/protocol/command" - "golang.org/x/tools/gopls/internal/settings" - "golang.org/x/tools/gopls/internal/util/bug" - "golang.org/x/tools/gopls/internal/util/slices" - "golang.org/x/tools/internal/event" -- "golang.org/x/tools/internal/event/tag" - "golang.org/x/tools/internal/imports" -) - @@ -43958,6 +44105,10 @@ diff -urN a/gopls/internal/golang/codeaction.go b/gopls/internal/golang/codeacti - // Only compute quick fixes if there are any diagnostics to fix. - wantQuickFixes := want[protocol.QuickFix] && len(diagnostics) > 0 - +- // Note: don't forget to update the allow-list in Server.CodeAction +- // when adding new query operations like GoTest and GoDoc that +- // are permitted even in generated source files +- - // Code actions requiring syntax information alone. - if wantQuickFixes || want[protocol.SourceOrganizeImports] || want[protocol.RefactorExtract] { - pgf, err := snapshot.ParseGo(ctx, fh, parsego.Full) @@ -43969,7 +44120,7 @@ diff -urN a/gopls/internal/golang/codeaction.go b/gopls/internal/golang/codeacti - if wantQuickFixes || want[protocol.SourceOrganizeImports] { - importEdits, importEditsPerFix, err := allImportsFixes(ctx, snapshot, pgf) - if err != nil { -- event.Error(ctx, "imports fixes", err, tag.File.Of(fh.URI().Path())) +- event.Error(ctx, "imports fixes", err, label.File.Of(fh.URI().Path())) - importEdits = nil - importEditsPerFix = nil - } @@ -44403,7 +44554,7 @@ diff -urN a/gopls/internal/golang/codeaction.go b/gopls/internal/golang/codeacti - -// getGoTestCodeActions returns any "run this test/benchmark" code actions for the selection. -func getGoTestCodeActions(pkg *cache.Package, pgf *parsego.File, rng protocol.Range) ([]protocol.CodeAction, error) { -- fns, err := TestsAndBenchmarks(pkg, pgf) +- fns, err := testsAndBenchmarks(pkg, pgf) - if err != nil { - return nil, err - } @@ -44489,7 +44640,7 @@ diff -urN a/gopls/internal/golang/code_lens.go b/gopls/internal/golang/code_lens - if err != nil { - return nil, err - } -- fns, err := TestsAndBenchmarks(pkg, pgf) +- fns, err := testsAndBenchmarks(pkg, pgf) - if err != nil { - return nil, err - } @@ -44545,7 +44696,7 @@ diff -urN a/gopls/internal/golang/code_lens.go b/gopls/internal/golang/code_lens - Benchmarks []TestFn -} - --func TestsAndBenchmarks(pkg *cache.Package, pgf *parsego.File) (TestFns, error) { +-func testsAndBenchmarks(pkg *cache.Package, pgf *parsego.File) (TestFns, error) { - var out TestFns - - if !strings.HasSuffix(pgf.URI.Path(), "_test.go") { @@ -44697,7 +44848,7 @@ diff -urN a/gopls/internal/golang/code_lens.go b/gopls/internal/golang/code_lens diff -urN a/gopls/internal/golang/comment.go b/gopls/internal/golang/comment.go --- a/gopls/internal/golang/comment.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/golang/comment.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,41 +0,0 @@ +@@ -1,177 +0,0 @@ -// Copyright 2022 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -44705,12 +44856,24 @@ diff -urN a/gopls/internal/golang/comment.go b/gopls/internal/golang/comment.go -package golang - -import ( +- "context" +- "errors" - "fmt" +- "go/ast" - "go/doc/comment" +- "go/token" +- "go/types" +- "strings" - +- "golang.org/x/tools/gopls/internal/cache" +- "golang.org/x/tools/gopls/internal/cache/parsego" +- "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/settings" +- "golang.org/x/tools/gopls/internal/util/safetoken" -) - +-var errNoCommentReference = errors.New("no comment reference found") +- -// CommentToMarkdown converts comment text to formatted markdown. -// The comment was prepared by DocReader, -// so it is known not to have leading, trailing blank lines @@ -44739,6 +44902,130 @@ diff -urN a/gopls/internal/golang/comment.go b/gopls/internal/golang/comment.go - easy := pr.Markdown(doc) - return string(easy) -} +- +-// docLinkDefinition finds the definition of the doc link in comments at pos. +-// If there is no reference at pos, returns errNoCommentReference. +-func docLinkDefinition(ctx context.Context, snapshot *cache.Snapshot, pkg *cache.Package, pgf *parsego.File, pos token.Pos) ([]protocol.Location, error) { +- obj, _, err := parseDocLink(pkg, pgf, pos) +- if err != nil { +- return nil, err +- } +- loc, err := mapPosition(ctx, pkg.FileSet(), snapshot, obj.Pos(), adjustedObjEnd(obj)) +- if err != nil { +- return nil, err +- } +- return []protocol.Location{loc}, nil +-} +- +-// parseDocLink parses a doc link in a comment such as [fmt.Println] +-// and returns the symbol at pos, along with the link's start position. +-func parseDocLink(pkg *cache.Package, pgf *parsego.File, pos token.Pos) (types.Object, protocol.Range, error) { +- var comment *ast.Comment +- for _, cg := range pgf.File.Comments { +- for _, c := range cg.List { +- if c.Pos() <= pos && pos <= c.End() { +- comment = c +- break +- } +- } +- if comment != nil { +- break +- } +- } +- if comment == nil { +- return nil, protocol.Range{}, errNoCommentReference +- } +- +- // The canonical parsing algorithm is defined by go/doc/comment, but +- // unfortunately its API provides no way to reliably reconstruct the +- // position of each doc link from the parsed result. +- line := safetoken.Line(pgf.Tok, pos) +- var start, end token.Pos +- if pgf.Tok.LineStart(line) > comment.Pos() { +- start = pgf.Tok.LineStart(line) +- } else { +- start = comment.Pos() +- } +- if line < pgf.Tok.LineCount() && pgf.Tok.LineStart(line+1) < comment.End() { +- end = pgf.Tok.LineStart(line + 1) +- } else { +- end = comment.End() +- } +- +- offsetStart, offsetEnd, err := safetoken.Offsets(pgf.Tok, start, end) +- if err != nil { +- return nil, protocol.Range{}, err +- } +- +- text := string(pgf.Src[offsetStart:offsetEnd]) +- lineOffset := int(pos - start) +- +- for _, idx := range docLinkRegex.FindAllStringSubmatchIndex(text, -1) { +- // The [idx[2], idx[3]) identifies the first submatch, +- // which is the reference name in the doc link. +- // e.g. The "[fmt.Println]" reference name is "fmt.Println". +- if !(idx[2] <= lineOffset && lineOffset < idx[3]) { +- continue +- } +- p := lineOffset - idx[2] +- name := text[idx[2]:idx[3]] +- i := strings.LastIndexByte(name, '.') +- for i != -1 { +- if p > i { +- break +- } +- name = name[:i] +- i = strings.LastIndexByte(name, '.') +- } +- obj := lookupObjectByName(pkg, pgf, name) +- if obj == nil { +- return nil, protocol.Range{}, errNoCommentReference +- } +- namePos := start + token.Pos(idx[2]+i+1) +- rng, err := pgf.PosRange(namePos, namePos+token.Pos(len(obj.Name()))) +- if err != nil { +- return nil, protocol.Range{}, err +- } +- return obj, rng, nil +- } +- +- return nil, protocol.Range{}, errNoCommentReference +-} +- +-func lookupObjectByName(pkg *cache.Package, pgf *parsego.File, name string) types.Object { +- scope := pkg.Types().Scope() +- fileScope := pkg.TypesInfo().Scopes[pgf.File] +- pkgName, suffix, _ := strings.Cut(name, ".") +- obj, ok := fileScope.Lookup(pkgName).(*types.PkgName) +- if ok { +- scope = obj.Imported().Scope() +- if suffix == "" { +- return obj +- } +- name = suffix +- } +- +- recv, method, ok := strings.Cut(name, ".") +- if ok { +- obj, ok := scope.Lookup(recv).(*types.TypeName) +- if !ok { +- return nil +- } +- t, ok := obj.Type().(*types.Named) +- if !ok { +- return nil +- } +- for i := 0; i < t.NumMethods(); i++ { +- m := t.Method(i) +- if m.Name() == method { +- return m +- } +- } +- return nil +- } +- +- return scope.Lookup(name) +-} diff -urN a/gopls/internal/golang/completion/builtin.go b/gopls/internal/golang/completion/builtin.go --- a/gopls/internal/golang/completion/builtin.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/golang/completion/builtin.go 1970-01-01 00:00:00.000000000 +0000 @@ -44893,7 +45180,7 @@ diff -urN a/gopls/internal/golang/completion/builtin.go b/gopls/internal/golang/ diff -urN a/gopls/internal/golang/completion/completion.go b/gopls/internal/golang/completion/completion.go --- a/gopls/internal/golang/completion/completion.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/golang/completion/completion.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,3356 +0,0 @@ +@@ -1,3346 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -45356,21 +45643,6 @@ diff -urN a/gopls/internal/golang/completion/completion.go b/gopls/internal/gola - return false -} - --// ErrIsDefinition is an error that informs the user they got no --// completions because they tried to complete the name of a new object --// being defined. --type ErrIsDefinition struct { -- objStr string --} -- --func (e ErrIsDefinition) Error() string { -- msg := "this is a definition" -- if e.objStr != "" { -- msg += " of " + e.objStr -- } -- return msg --} -- -// Completion returns a list of possible candidates for completion, given a -// a file and a position. -// @@ -45426,19 +45698,16 @@ diff -urN a/gopls/internal/golang/completion/completion.go b/gopls/internal/gola - return nil, nil, nil - } - case *ast.Ident: -- // reject defining identifiers +- // Don't offer completions for (most) defining identifiers. - if obj, ok := pkg.TypesInfo().Defs[n]; ok { - if v, ok := obj.(*types.Var); ok && v.IsField() && v.Embedded() { -- // An anonymous field is also a reference to a type. +- // Allow completion of anonymous fields, since they may reference type +- // names. - } else if pgf.File.Name == n { -- // Don't skip completions if Ident is for package name. -- break +- // Allow package name completion. - } else { -- objStr := "" -- if obj != nil { -- qual := types.RelativeTo(pkg.Types()) -- objStr = types.ObjectString(obj, qual) -- } +- // Check if we have special completion for this definition, such as +- // test function name completion. - ans, sel := definition(path, obj, pgf) - if ans != nil { - sort.Slice(ans, func(i, j int) bool { @@ -45446,7 +45715,8 @@ diff -urN a/gopls/internal/golang/completion/completion.go b/gopls/internal/gola - }) - return ans, sel, nil - } -- return nil, nil, ErrIsDefinition{objStr: objStr} +- +- return nil, nil, nil // No completions. - } - } - } @@ -47849,6 +48119,13 @@ diff -urN a/gopls/internal/golang/completion/completion.go b/gopls/internal/gola - - for _, expType := range expTypes { - if isEmptyInterface(expType) { +- // If any type matches the expected type, fall back to other +- // considerations below. +- // +- // TODO(rfindley): can this be expressed via scoring, rather than a boolean? +- // Why is it the case that we break ties for the empty interface, but +- // not for other expected types that may be satisfied by a lot of +- // types, such as fmt.Stringer? - continue - } - @@ -52417,7 +52694,7 @@ diff -urN a/gopls/internal/golang/completion/statements.go b/gopls/internal/gola diff -urN a/gopls/internal/golang/completion/util.go b/gopls/internal/golang/completion/util.go --- a/gopls/internal/golang/completion/util.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/golang/completion/util.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,334 +0,0 @@ +@@ -1,341 +0,0 @@ -// Copyright 2020 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -52562,10 +52839,17 @@ diff -urN a/gopls/internal/golang/completion/util.go b/gopls/internal/golang/com -// TODO(adonovan): shouldn't this use CoreType(T)? -func isPointer(T types.Type) bool { return is[*types.Pointer](aliases.Unalias(T)) } - +-// isEmptyInterface whether T is a (possibly Named or Alias) empty interface +-// type, such that every type is assignable to T. +-// +-// isEmptyInterface returns false for type parameters, since they have +-// different assignability rules. -func isEmptyInterface(T types.Type) bool { -- // TODO(adonovan): shouldn't this use Underlying? -- intf, _ := T.(*types.Interface) -- return intf != nil && intf.NumMethods() == 0 && intf.IsMethodSet() +- if _, ok := T.(*types.TypeParam); ok { +- return false +- } +- intf, _ := T.Underlying().(*types.Interface) +- return intf != nil && intf.Empty() -} - -func isUntyped(T types.Type) bool { @@ -52787,7 +53071,7 @@ diff -urN a/gopls/internal/golang/completion/util_test.go b/gopls/internal/golan diff -urN a/gopls/internal/golang/definition.go b/gopls/internal/golang/definition.go --- a/gopls/internal/golang/definition.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/golang/definition.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,312 +0,0 @@ +@@ -1,318 +0,0 @@ -// Copyright 2023 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -52856,13 +53140,19 @@ diff -urN a/gopls/internal/golang/definition.go b/gopls/internal/golang/definiti - // Handle the case where the cursor is in a linkname directive. - locations, err := LinknameDefinition(ctx, snapshot, pgf.Mapper, position) - if !errors.Is(err, ErrNoLinkname) { -- return locations, err +- return locations, err // may be success or failure - } - - // Handle the case where the cursor is in an embed directive. - locations, err = EmbedDefinition(pgf.Mapper, position) - if !errors.Is(err, ErrNoEmbed) { -- return locations, err +- return locations, err // may be success or failure +- } +- +- // Handle the case where the cursor is in a doc link. +- locations, err = docLinkDefinition(ctx, snapshot, pkg, pgf, pos) +- if !errors.Is(err, errNoCommentReference) { +- return locations, err // may be success or failure - } - - // The general case: the cursor is on an identifier. @@ -53103,7 +53393,7 @@ diff -urN a/gopls/internal/golang/definition.go b/gopls/internal/golang/definiti diff -urN a/gopls/internal/golang/diagnostics.go b/gopls/internal/golang/diagnostics.go --- a/gopls/internal/golang/diagnostics.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/golang/diagnostics.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,48 +0,0 @@ +@@ -1,42 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -53125,6 +53415,8 @@ diff -urN a/gopls/internal/golang/diagnostics.go b/gopls/internal/golang/diagnos -// -// If the provided tracker is non-nil, it may be used to provide notifications -// of the ongoing analysis pass. +-// +-// TODO(rfindley): merge this with snapshot.Analyze. -func Analyze(ctx context.Context, snapshot *cache.Snapshot, pkgIDs map[PackageID]*metadata.Package, tracker *progress.Tracker) (map[protocol.DocumentURI][]*cache.Diagnostic, error) { - // Exit early if the context has been canceled. This also protects us - // from a race on Options, see golang/go#36699. @@ -53132,17 +53424,9 @@ diff -urN a/gopls/internal/golang/diagnostics.go b/gopls/internal/golang/diagnos - return nil, ctx.Err() - } - -- options := snapshot.Options() -- categories := []map[string]*settings.Analyzer{ -- options.DefaultAnalyzers, -- options.StaticcheckAnalyzers, -- } -- -- var analyzers []*settings.Analyzer -- for _, cat := range categories { -- for _, a := range cat { -- analyzers = append(analyzers, a) -- } +- analyzers := maps.Values(settings.DefaultAnalyzers) +- if snapshot.Options().Staticcheck { +- analyzers = append(analyzers, maps.Values(settings.StaticcheckAnalyzers)...) - } - - analysisDiagnostics, err := snapshot.Analyze(ctx, pkgIDs, analyzers, tracker) @@ -55151,7 +55435,7 @@ diff -urN a/gopls/internal/golang/folding_range.go b/gopls/internal/golang/foldi diff -urN a/gopls/internal/golang/format.go b/gopls/internal/golang/format.go --- a/gopls/internal/golang/format.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/golang/format.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,337 +0,0 @@ +@@ -1,338 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -55175,6 +55459,7 @@ diff -urN a/gopls/internal/golang/format.go b/gopls/internal/golang/format.go - "golang.org/x/tools/gopls/internal/cache/parsego" - "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/protocol" +- "golang.org/x/tools/gopls/internal/settings" - "golang.org/x/tools/gopls/internal/util/safetoken" - "golang.org/x/tools/internal/diff" - "golang.org/x/tools/internal/event" @@ -55220,7 +55505,7 @@ diff -urN a/gopls/internal/golang/format.go b/gopls/internal/golang/format.go - - // Apply additional formatting, if any is supported. Currently, the only - // supported additional formatter is gofumpt. -- if format := snapshot.Options().GofumptFormat; snapshot.Options().Gofumpt && format != nil { +- if format := settings.GofumptFormat; snapshot.Options().Gofumpt && format != nil { - // gofumpt can customize formatting based on language version and module - // path, if available. - // @@ -55267,14 +55552,14 @@ diff -urN a/gopls/internal/golang/format.go b/gopls/internal/golang/format.go -// it returns a list of fixes that could be applied to the file, with the -// corresponding TextEdits that would be needed to apply that fix. -func allImportsFixes(ctx context.Context, snapshot *cache.Snapshot, pgf *parsego.File) (allFixEdits []protocol.TextEdit, editsPerFix []*importFix, err error) { -- ctx, done := event.Start(ctx, "golang.AllImportsFixes") +- ctx, done := event.Start(ctx, "golang.allImportsFixes") - defer done() - - if err := snapshot.RunProcessEnvFunc(ctx, func(ctx context.Context, opts *imports.Options) error { - allFixEdits, editsPerFix, err = computeImportEdits(ctx, pgf, opts) - return err - }); err != nil { -- return nil, nil, fmt.Errorf("AllImportsFixes: %v", err) +- return nil, nil, fmt.Errorf("allImportsFixes: %v", err) - } - return allFixEdits, editsPerFix, nil -} @@ -55571,7 +55856,7 @@ diff -urN a/gopls/internal/golang/format_test.go b/gopls/internal/golang/format_ diff -urN a/gopls/internal/golang/gc_annotations.go b/gopls/internal/golang/gc_annotations.go --- a/gopls/internal/golang/gc_annotations.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/golang/gc_annotations.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,208 +0,0 @@ +@@ -1,214 +0,0 @@ -// Copyright 2020 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -55591,6 +55876,7 @@ diff -urN a/gopls/internal/golang/gc_annotations.go b/gopls/internal/golang/gc_a - "golang.org/x/tools/gopls/internal/cache/metadata" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/settings" +- "golang.org/x/tools/internal/event" - "golang.org/x/tools/internal/gocommand" -) - @@ -55599,11 +55885,16 @@ diff -urN a/gopls/internal/golang/gc_annotations.go b/gopls/internal/golang/gc_a - return nil, nil - } - pkgDir := filepath.Dir(mp.CompiledGoFiles[0].Path()) -- outDir := filepath.Join(os.TempDir(), fmt.Sprintf("gopls-%d.details", os.Getpid())) -- -- if err := os.MkdirAll(outDir, 0700); err != nil { +- outDir, err := os.MkdirTemp("", fmt.Sprintf("gopls-%d.details", os.Getpid())) +- if err != nil { - return nil, err - } +- defer func() { +- if err := os.RemoveAll(outDir); err != nil { +- event.Error(ctx, "cleaning gcdetails dir", err) +- } +- }() +- - tmpFile, err := os.CreateTemp(os.TempDir(), "gopls-x") - if err != nil { - return nil, err @@ -56315,7 +56606,7 @@ diff -urN a/gopls/internal/golang/highlight.go b/gopls/internal/golang/highlight diff -urN a/gopls/internal/golang/hover.go b/gopls/internal/golang/hover.go --- a/gopls/internal/golang/hover.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/golang/hover.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,1411 +0,0 @@ +@@ -1,1435 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -56351,6 +56642,7 @@ diff -urN a/gopls/internal/golang/hover.go b/gopls/internal/golang/hover.go - "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/settings" +- gastutil "golang.org/x/tools/gopls/internal/util/astutil" - "golang.org/x/tools/gopls/internal/util/bug" - "golang.org/x/tools/gopls/internal/util/safetoken" - "golang.org/x/tools/gopls/internal/util/slices" @@ -56452,45 +56744,31 @@ diff -urN a/gopls/internal/golang/hover.go b/gopls/internal/golang/hover.go - return protocol.Range{}, nil, err - } - -- // Handle hovering over import paths, which do not have an associated -- // identifier. -- for _, spec := range pgf.File.Imports { -- // We are inclusive of the end point here to allow hovering when the cursor -- // is just after the import path. -- if spec.Path.Pos() <= pos && pos <= spec.Path.End() { -- return hoverImport(ctx, snapshot, pkg, pgf, spec) -- } -- } -- - // Handle hovering over the package name, which does not have an associated - // object. - // As with import paths, we allow hovering just after the package name. -- if pgf.File.Name != nil && pgf.File.Name.Pos() <= pos && pos <= pgf.File.Name.Pos() { +- if pgf.File.Name != nil && gastutil.NodeContains(pgf.File.Name, pos) { - return hoverPackageName(pkg, pgf) - } - -- // Handle hovering over (non-import-path) literals. -- if path, _ := astutil.PathEnclosingInterval(pgf.File, pos, pos); len(path) > 0 { -- if lit, _ := path[0].(*ast.BasicLit); lit != nil { -- return hoverLit(pgf, lit, pos) -- } -- } -- - // Handle hovering over embed directive argument. - pattern, embedRng := parseEmbedDirective(pgf.Mapper, pp) - if pattern != "" { - return hoverEmbed(fh, embedRng, pattern) - } - +- // hoverRange is the range reported to the client (e.g. for highlighting). +- // It may be an expansion around the selected identifier, +- // for instance when hovering over a linkname directive or doc link. +- var hoverRange *protocol.Range - // Handle linkname directive by overriding what to look for. -- var linkedRange *protocol.Range // range referenced by linkname directive, or nil - if pkgPath, name, offset := parseLinkname(pgf.Mapper, pp); pkgPath != "" && name != "" { - // rng covering 2nd linkname argument: pkgPath.name. - rng, err := pgf.PosRange(pgf.Tok.Pos(offset), pgf.Tok.Pos(offset+len(pkgPath)+len(".")+len(name))) - if err != nil { - return protocol.Range{}, nil, fmt.Errorf("range over linkname arg: %w", err) - } -- linkedRange = &rng +- hoverRange = &rng - - pkg, pgf, pos, err = findLinkname(ctx, snapshot, PackagePath(pkgPath), name) - if err != nil { @@ -56498,6 +56776,45 @@ diff -urN a/gopls/internal/golang/hover.go b/gopls/internal/golang/hover.go - } - } - +- // Handle hovering over a doc link +- if obj, rng, _ := parseDocLink(pkg, pgf, pos); obj != nil { +- hoverRange = &rng +- // Handle builtins, which don't have a package or position. +- if !obj.Pos().IsValid() { +- h, err := hoverBuiltin(ctx, snapshot, obj) +- return *hoverRange, h, err +- } +- objURI := safetoken.StartPosition(pkg.FileSet(), obj.Pos()) +- pkg, pgf, err = NarrowestPackageForFile(ctx, snapshot, protocol.URIFromPath(objURI.Filename)) +- if err != nil { +- return protocol.Range{}, nil, err +- } +- pos = pgf.Tok.Pos(objURI.Offset) +- } +- +- // Handle hovering over import paths, which do not have an associated +- // identifier. +- for _, spec := range pgf.File.Imports { +- if gastutil.NodeContains(spec, pos) { +- rng, hoverJSON, err := hoverImport(ctx, snapshot, pkg, pgf, spec) +- if err != nil { +- return protocol.Range{}, nil, err +- } +- if hoverRange == nil { +- hoverRange = &rng +- } +- return *hoverRange, hoverJSON, nil +- } +- } +- // Handle hovering over (non-import-path) literals. +- if path, _ := astutil.PathEnclosingInterval(pgf.File, pos, pos); len(path) > 0 { +- if lit, _ := path[0].(*ast.BasicLit); lit != nil { +- return hoverLit(pgf, lit, pos) +- } +- } +- +- // Handle hover over identifier. +- - // The general case: compute hover information for the object referenced by - // the identifier at pos. - ident, obj, selectedType := referencedObject(pkg, pgf, pos) @@ -56506,14 +56823,12 @@ diff -urN a/gopls/internal/golang/hover.go b/gopls/internal/golang/hover.go - } - - // Unless otherwise specified, rng covers the ident being hovered. -- var rng protocol.Range -- if linkedRange != nil { -- rng = *linkedRange -- } else { -- rng, err = pgf.NodeRange(ident) +- if hoverRange == nil { +- rng, err := pgf.NodeRange(ident) - if err != nil { - return protocol.Range{}, nil, err - } +- hoverRange = &rng - } - - // By convention, we qualify hover information relative to the package @@ -56527,7 +56842,7 @@ diff -urN a/gopls/internal/golang/hover.go b/gopls/internal/golang/hover.go - if selectedType != nil { - fakeObj := types.NewVar(obj.Pos(), obj.Pkg(), obj.Name(), selectedType) - signature := types.ObjectString(fakeObj, qf) -- return rng, &hoverJSON{ +- return *hoverRange, &hoverJSON{ - Signature: signature, - SingleLine: signature, - SymbolName: fakeObj.Name(), @@ -56537,7 +56852,7 @@ diff -urN a/gopls/internal/golang/hover.go b/gopls/internal/golang/hover.go - // Handle builtins, which don't have a package or position. - if !obj.Pos().IsValid() { - h, err := hoverBuiltin(ctx, snapshot, obj) -- return rng, h, err +- return *hoverRange, h, err - } - - // For all other objects, consider the full syntax of their declaration in @@ -56841,7 +57156,7 @@ diff -urN a/gopls/internal/golang/hover.go b/gopls/internal/golang/hover.go - linkPath = strings.Replace(linkPath, mod.Path, mod.Path+"@"+mod.Version, 1) - } - -- return rng, &hoverJSON{ +- return *hoverRange, &hoverJSON{ - Synopsis: doc.Synopsis(docText), - FullDocumentation: docText, - SingleLine: singleLineSignature, @@ -58028,7 +58343,7 @@ diff -urN a/gopls/internal/golang/identifier_test.go b/gopls/internal/golang/ide diff -urN a/gopls/internal/golang/implementation.go b/gopls/internal/golang/implementation.go --- a/gopls/internal/golang/implementation.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/golang/implementation.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,497 +0,0 @@ +@@ -1,543 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -58104,19 +58419,29 @@ diff -urN a/gopls/internal/golang/implementation.go b/gopls/internal/golang/impl -} - -func implementations(ctx context.Context, snapshot *cache.Snapshot, fh file.Handle, pp protocol.Position) ([]protocol.Location, error) { +- // First, find the object referenced at the cursor by type checking the +- // current package. - obj, pkg, err := implementsObj(ctx, snapshot, fh.URI(), pp) - if err != nil { - return nil, err - } - -- var localPkgs []*cache.Package +- // If the resulting object has a position, we can expand the search to types +- // in the declaring package(s). In this case, we must re-type check these +- // packages in the same realm. +- var ( +- declOffset int +- declURI protocol.DocumentURI +- localPkgs []*cache.Package +- ) - if obj.Pos().IsValid() { // no local package for error or error.Error - declPosn := safetoken.StartPosition(pkg.FileSet(), obj.Pos()) +- declOffset = declPosn.Offset - // Type-check the declaring package (incl. variants) for use - // by the "local" search, which uses type information to - // enumerate all types within the package that satisfy the - // query type, even those defined local to a function. -- declURI := protocol.URIFromPath(declPosn.Filename) +- declURI = protocol.URIFromPath(declPosn.Filename) - declMPs, err := snapshot.MetadataForFile(ctx, declURI) - if err != nil { - return nil, err @@ -58135,20 +58460,25 @@ diff -urN a/gopls/internal/golang/implementation.go b/gopls/internal/golang/impl - } - } - +- pkg = nil // no longer used +- - // Is the selected identifier a type name or method? - // (For methods, report the corresponding method names.) -- var queryType types.Type -- var queryMethodID string -- switch obj := obj.(type) { -- case *types.TypeName: -- queryType = obj.Type() -- case *types.Func: -- // For methods, use the receiver type, which may be anonymous. -- if recv := obj.Type().(*types.Signature).Recv(); recv != nil { -- queryType = recv.Type() -- queryMethodID = obj.Id() +- // +- // This logic is reused for local queries. +- typeOrMethod := func(obj types.Object) (types.Type, string) { +- switch obj := obj.(type) { +- case *types.TypeName: +- return obj.Type(), "" +- case *types.Func: +- // For methods, use the receiver type, which may be anonymous. +- if recv := obj.Type().(*types.Signature).Recv(); recv != nil { +- return recv.Type(), obj.Id() +- } - } +- return nil, "" - } +- queryType, queryMethodID := typeOrMethod(obj) - if queryType == nil { - return nil, bug.Errorf("%s is not a type or method", obj.Name()) // should have been handled by implementsObj - } @@ -58200,11 +58530,42 @@ diff -urN a/gopls/internal/golang/implementation.go b/gopls/internal/golang/impl - ) - // local search - for _, localPkg := range localPkgs { -- localPkg := localPkg +- // The localImplementations algorithm assumes needle and haystack +- // belong to a single package (="realm" of types symbol identities), +- // so we need to recompute obj for each local package. +- // (By contrast the global algorithm is name-based.) +- declPkg := localPkg - group.Go(func() error { -- localLocs, err := localImplementations(ctx, snapshot, localPkg, queryType, queryMethodID) +- pkgID := declPkg.Metadata().ID +- declFile, err := declPkg.File(declURI) - if err != nil { -- return err +- return err // "can't happen" +- } +- +- // Find declaration of corresponding object +- // in this package based on (URI, offset). +- pos, err := safetoken.Pos(declFile.Tok, declOffset) +- if err != nil { +- return err // also "can't happen" +- } +- // TODO(adonovan): simplify: use objectsAt? +- path := pathEnclosingObjNode(declFile.File, pos) +- if path == nil { +- return ErrNoIdentFound // checked earlier +- } +- id, ok := path[0].(*ast.Ident) +- if !ok { +- return ErrNoIdentFound // checked earlier +- } +- // Shadow obj, queryType, and queryMethodID in this package. +- obj := declPkg.TypesInfo().ObjectOf(id) // may be nil +- queryType, queryMethodID := typeOrMethod(obj) +- if queryType == nil { +- return fmt.Errorf("querying method sets in package %q: %v", pkgID, err) +- } +- localLocs, err := localImplementations(ctx, snapshot, declPkg, queryType, queryMethodID) +- if err != nil { +- return fmt.Errorf("querying local implementations %q: %v", pkgID, err) - } - locsMu.Lock() - locs = append(locs, localLocs...) @@ -58529,7 +58890,7 @@ diff -urN a/gopls/internal/golang/implementation.go b/gopls/internal/golang/impl diff -urN a/gopls/internal/golang/inlay_hint.go b/gopls/internal/golang/inlay_hint.go --- a/gopls/internal/golang/inlay_hint.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/golang/inlay_hint.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,396 +0,0 @@ +@@ -1,400 +0,0 @@ -// Copyright 2022 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -58671,7 +59032,11 @@ diff -urN a/gopls/internal/golang/inlay_hint.go b/gopls/internal/golang/inlay_hi - if !ok { - return nil - } -- signature, ok := typeparams.CoreType(info.TypeOf(callExpr.Fun)).(*types.Signature) +- t := info.TypeOf(callExpr.Fun) +- if t == nil { +- return nil +- } +- signature, ok := typeparams.CoreType(t).(*types.Signature) - if !ok { - return nil - } @@ -59125,11 +59490,11 @@ diff -urN a/gopls/internal/golang/inline_all.go b/gopls/internal/golang/inline_a - Call: calls[currentCall], - Content: content, - } -- var err error -- content, err = inline.Inline(logf, caller, callee) +- res, err := inline.Inline(caller, callee, &inline.Options{Logf: logf}) - if err != nil { - return nil, fmt.Errorf("inlining failed: %v", err) - } +- content = res.Content - if post != nil { - content = post(content) - } @@ -59325,14 +59690,14 @@ diff -urN a/gopls/internal/golang/inline.go b/gopls/internal/golang/inline.go - Content: callerPGF.Src, - } - -- got, err := inline.Inline(logf, caller, callee) +- res, err := inline.Inline(caller, callee, &inline.Options{Logf: logf}) - if err != nil { - return nil, nil, err - } - - return callerPkg.FileSet(), &analysis.SuggestedFix{ - Message: fmt.Sprintf("inline call of %v", callee), -- TextEdits: diffToTextEdits(callerPGF.Tok, diff.Bytes(callerPGF.Src, got)), +- TextEdits: diffToTextEdits(callerPGF.Tok, diff.Bytes(callerPGF.Src, res.Content)), - }, nil -} - @@ -60209,7 +60574,7 @@ diff -urN a/gopls/internal/golang/origin.go b/gopls/internal/golang/origin.go diff -urN a/gopls/internal/golang/pkgdoc.go b/gopls/internal/golang/pkgdoc.go --- a/gopls/internal/golang/pkgdoc.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/golang/pkgdoc.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,633 +0,0 @@ +@@ -1,813 +0,0 @@ -// Copyright 2024 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -60237,6 +60602,9 @@ diff -urN a/gopls/internal/golang/pkgdoc.go b/gopls/internal/golang/pkgdoc.go -// - modify JS httpGET function to give a transient visual indication -// when clicking a source link that the editor is being navigated -// (in case it doesn't raise itself, like VS Code). +-// - move this into a new package, golang/pkgdoc, and then +-// split out the various helpers without fear of polluting +-// the golang package namespace. - -import ( - "bytes" @@ -60250,6 +60618,7 @@ diff -urN a/gopls/internal/golang/pkgdoc.go b/gopls/internal/golang/pkgdoc.go - "html" - "log" - "path/filepath" +- "strings" - - "golang.org/x/tools/gopls/internal/cache" - "golang.org/x/tools/gopls/internal/protocol" @@ -60393,12 +60762,19 @@ diff -urN a/gopls/internal/golang/pkgdoc.go b/gopls/internal/golang/pkgdoc.go - } - } - +- scope := pkg.Types().Scope() +- escape := html.EscapeString +- +- title := fmt.Sprintf("%s package - %s - Gopls packages", +- pkg.Types().Name(), escape(pkg.Types().Path())) +- - var buf bytes.Buffer - buf.WriteString(` - - - - +- ` + title + ` - - - +-
-
Gopls server has terminated. Page is inactive.
+-\n") +- fmt.Fprintf(&buf, "
\n") +- +- // -- main element -- - - // sourceLink returns HTML for a link to open a file in the client editor. - sourceLink := func(text, url string) string { @@ -60559,16 +61023,68 @@ diff -urN a/gopls/internal/golang/pkgdoc.go b/gopls/internal/golang/pkgdoc.go - return escape(buf.String()) - } - -- // pkgRelative qualifies types by package name alone -- pkgRelative := func(other *types.Package) string { -- if pkg.Types() == other { -- return "" // same package; unqualified +- // fnString is like fn.String() except that it: +- // - shows the receiver name; +- // - uses space "(T) M()" not dot "(T).M()" after receiver; +- // - doesn't bother with the special case for interface receivers +- // since it is unreachable for the methods in go/doc. +- // - elides parameters after the first three: f(a, b, c, ...). +- fnString := func(fn *types.Func) string { +- // pkgRelative qualifies types by package name alone +- pkgRelative := func(other *types.Package) string { +- if pkg.Types() == other { +- return "" // same package; unqualified +- } +- return other.Name() - } -- return other.Name() -- } +- +- sig := fn.Type().(*types.Signature) +- +- // Emit "func (recv T) F". +- var buf bytes.Buffer +- buf.WriteString("func ") +- if recv := sig.Recv(); recv != nil { +- buf.WriteByte('(') +- if recv.Name() != "" { +- buf.WriteString(recv.Name()) +- buf.WriteByte(' ') +- } +- types.WriteType(&buf, recv.Type(), pkgRelative) +- buf.WriteByte(')') +- buf.WriteByte(' ') // (ObjectString uses a '.' here) +- } else if pkg := fn.Pkg(); pkg != nil { +- if s := pkgRelative(pkg); s != "" { +- buf.WriteString(s) +- buf.WriteByte('.') +- } +- } +- buf.WriteString(fn.Name()) +- +- // Emit signature. +- // +- // Elide parameters after the third one. +- // WriteSignature is too complex to fork, so we replace +- // parameters 4+ with "invalid type", format, +- // then post-process the string. +- if sig.Params().Len() > 3 { +- sig = types.NewSignatureType( +- sig.Recv(), +- typesSeqToSlice[*types.TypeParam](sig.RecvTypeParams()), +- typesSeqToSlice[*types.TypeParam](sig.TypeParams()), +- types.NewTuple(append( +- typesSeqToSlice[*types.Var](sig.Params())[:3], +- types.NewVar(0, nil, "", types.Typ[types.Invalid]))...), +- sig.Results(), +- sig.Variadic()) +- } +- types.WriteSignature(&buf, sig, pkgRelative) +- return strings.ReplaceAll(buf.String(), ", invalid type)", ", ...)") +- } +- +- fmt.Fprintf(&buf, "
\n") - - // package name -- fmt.Fprintf(&buf, "

Package %s

\n", pkg.Types().Name()) +- fmt.Fprintf(&buf, "

Package %s

\n", pkg.Types().Name()) - - // import path - fmt.Fprintf(&buf, "
import %q
\n", pkg.Types().Path()) @@ -60581,7 +61097,7 @@ diff -urN a/gopls/internal/golang/pkgdoc.go b/gopls/internal/golang/pkgdoc.go - fmt.Fprintf(&buf, "
%s
\n", docHTML(docpkg.Doc)) - - // symbol index -- fmt.Fprintf(&buf, "

Index

\n") +- fmt.Fprintf(&buf, "

Index

\n") - fmt.Fprintf(&buf, "\n") - } @@ -60659,7 +61169,7 @@ diff -urN a/gopls/internal/golang/pkgdoc.go b/gopls/internal/golang/pkgdoc.go - } - - // package-level functions -- fmt.Fprintf(&buf, "

Functions

\n") +- fmt.Fprintf(&buf, "

Functions

\n") - // funcs emits a list of package-level functions, - // possibly organized beneath the type they construct. - funcs := func(funcs []*doc.Func) { @@ -60679,7 +61189,7 @@ diff -urN a/gopls/internal/golang/pkgdoc.go b/gopls/internal/golang/pkgdoc.go - funcs(docpkg.Funcs) - - // types and their subelements -- fmt.Fprintf(&buf, "

Types

\n") +- fmt.Fprintf(&buf, "

Types

\n") - for _, doctype := range docpkg.Types { - tname := scope.Lookup(doctype.Name).(*types.TypeName) - @@ -60718,15 +61228,35 @@ diff -urN a/gopls/internal/golang/pkgdoc.go b/gopls/internal/golang/pkgdoc.go - } - - // source files -- fmt.Fprintf(&buf, "

Source files

\n") +- fmt.Fprintf(&buf, "

Source files

\n") - for _, filename := range docpkg.Filenames { - fmt.Fprintf(&buf, "
%s
\n", - sourceLink(filepath.Base(filename), posURL(filename, 1, 1))) - } - +- fmt.Fprintf(&buf, "
\n") +- fmt.Fprintf(&buf, "\n") +- fmt.Fprintf(&buf, "\n") +- - return buf.Bytes(), nil -} - +-// typesSeq abstracts various go/types sequence types: +-// MethodSet, Tuple, TypeParamList, TypeList. +-// TODO(adonovan): replace with go1.23 iterators. +-type typesSeq[T any] interface { +- Len() int +- At(int) T +-} +- +-func typesSeqToSlice[T any](seq typesSeq[T]) []T { +- slice := make([]T, seq.Len()) +- for i := range slice { +- slice[i] = seq.At(i) +- } +- return slice +-} +- -// (partly taken from pkgsite's typography.css) -const pkgDocStyle = ` -body { @@ -60833,6 +61363,21 @@ diff -urN a/gopls/internal/golang/pkgdoc.go b/gopls/internal/golang/pkgdoc.go - -#pkgsite { height: 1.5em; } - +-header { +- position: sticky; +- top: 0; +- left: 0; +- width: 100%; +- padding: 0.3em; +-} +- +-#hdr-Selector { +- margin-right: 0.3em; +- float: right; +- min-width: 25em; +- padding: 0.3em; +-} +- -#disconnected { - position: fixed; - top: 1em; @@ -63953,7 +64498,7 @@ diff -urN a/gopls/internal/golang/rename.go b/gopls/internal/golang/rename.go diff -urN a/gopls/internal/golang/semtok.go b/gopls/internal/golang/semtok.go --- a/gopls/internal/golang/semtok.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/golang/semtok.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,956 +0,0 @@ +@@ -1,960 +0,0 @@ -// Copyright 2024 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -64098,6 +64643,10 @@ diff -urN a/gopls/internal/golang/semtok.go b/gopls/internal/golang/semtok.go - - for _, cg := range f.Comments { - for _, c := range cg.List { +- // Only look at the comment that overlap the range. +- if c.End() <= tv.start || c.Pos() >= tv.end { +- continue +- } - tv.comment(c, importByName) - } - } @@ -64913,7 +65462,7 @@ diff -urN a/gopls/internal/golang/semtok.go b/gopls/internal/golang/semtok.go diff -urN a/gopls/internal/golang/signature_help.go b/gopls/internal/golang/signature_help.go --- a/gopls/internal/golang/signature_help.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/golang/signature_help.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,204 +0,0 @@ +@@ -1,212 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -64938,6 +65487,9 @@ diff -urN a/gopls/internal/golang/signature_help.go b/gopls/internal/golang/sign - "golang.org/x/tools/internal/event" -) - +-// SignatureHelp returns information about the signature of the innermost +-// function call enclosing the position, or nil if there is none. +-// On success it also returns the parameter index of the position. -func SignatureHelp(ctx context.Context, snapshot *cache.Snapshot, fh file.Handle, position protocol.Position) (*protocol.SignatureInformation, int, error) { - ctx, done := event.Start(ctx, "golang.SignatureHelp") - defer done() @@ -64970,16 +65522,21 @@ diff -urN a/gopls/internal/golang/signature_help.go b/gopls/internal/golang/sign - // The user is within an anonymous function, - // which may be the parameter to the *ast.CallExpr. - // Don't show signature help in this case. -- return nil, 0, fmt.Errorf("no signature help within a function declaration") +- return nil, 0, nil - case *ast.BasicLit: - if node.Kind == token.STRING { -- return nil, 0, fmt.Errorf("no signature help within a string literal") +- // golang/go#43397: don't offer signature help when the user is typing +- // in a string literal. Most LSP clients use ( or , as trigger +- // characters, but within a string literal these should not trigger +- // signature help (and it can be annoying when this happens after +- // you've already dismissed the help!). +- return nil, 0, nil - } - } - - } - if callExpr == nil || callExpr.Fun == nil { -- return nil, 0, fmt.Errorf("cannot find an enclosing function") +- return nil, 0, nil - } - - info := pkg.TypesInfo() @@ -64989,9 +65546,9 @@ diff -urN a/gopls/internal/golang/signature_help.go b/gopls/internal/golang/sign - if tv, ok := info.Types[callExpr.Fun]; !ok { - return nil, 0, fmt.Errorf("cannot get type for Fun %[1]T (%[1]v)", callExpr.Fun) - } else if tv.IsType() { -- return nil, 0, fmt.Errorf("this is a conversion to %s, not a call", tv.Type) +- return nil, 0, nil // a conversion, not a call - } else if sig, ok = tv.Type.Underlying().(*types.Signature); !ok { -- return nil, 0, fmt.Errorf("cannot find signature for Fun %[1]T (%[1]v)", callExpr.Fun) +- return nil, 0, fmt.Errorf("call operand is not a func or type: %[1]T (%[1]v)", callExpr.Fun) - } - // Inv: sig != nil - @@ -65858,7 +66415,7 @@ diff -urN a/gopls/internal/golang/type_definition.go b/gopls/internal/golang/typ diff -urN a/gopls/internal/golang/types_format.go b/gopls/internal/golang/types_format.go --- a/gopls/internal/golang/types_format.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/golang/types_format.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,525 +0,0 @@ +@@ -1,524 +0,0 @@ -// Copyright 2020 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -65881,7 +66438,6 @@ diff -urN a/gopls/internal/golang/types_format.go b/gopls/internal/golang/types_ - "golang.org/x/tools/gopls/internal/settings" - "golang.org/x/tools/gopls/internal/util/bug" - "golang.org/x/tools/internal/event" -- "golang.org/x/tools/internal/event/tag" - "golang.org/x/tools/internal/tokeninternal" - "golang.org/x/tools/internal/typeparams" -) @@ -66015,7 +66571,7 @@ diff -urN a/gopls/internal/golang/types_format.go b/gopls/internal/golang/types_ - cfg := printer.Config{Mode: printer.UseSpaces | printer.TabIndent, Tabwidth: 4} - b := &bytes.Buffer{} - if err := cfg.Fprint(b, fset, p.Type); err != nil { -- event.Error(ctx, "unable to print type", nil, tag.Type.Of(p.Type)) +- event.Error(ctx, fmt.Sprintf("error printing type %s", types.ExprString(p.Type)), err) - continue - } - typ := replacer.Replace(b.String()) @@ -67426,93 +67982,50 @@ diff -urN a/gopls/internal/golang/workspace_symbol_test.go b/gopls/internal/gola - } - } -} -diff -urN a/gopls/internal/hooks/analysis_119.go b/gopls/internal/hooks/analysis_119.go ---- a/gopls/internal/hooks/analysis_119.go 2000-01-01 00:00:00.000000000 -0000 -+++ b/gopls/internal/hooks/analysis_119.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,14 +0,0 @@ --// Copyright 2021 The Go Authors. All rights reserved. --// Use of this source code is governed by a BSD-style --// license that can be found in the LICENSE file. -- --//go:build !go1.20 --// +build !go1.20 -- --package hooks -- --import "golang.org/x/tools/gopls/internal/settings" -- --func updateAnalyzers(options *settings.Options) { -- options.StaticcheckSupported = false --} -diff -urN a/gopls/internal/hooks/analysis_120.go b/gopls/internal/hooks/analysis_120.go ---- a/gopls/internal/hooks/analysis_120.go 2000-01-01 00:00:00.000000000 -0000 -+++ b/gopls/internal/hooks/analysis_120.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,62 +0,0 @@ +diff -urN a/gopls/internal/label/keys.go b/gopls/internal/label/keys.go +--- a/gopls/internal/label/keys.go 2000-01-01 00:00:00.000000000 -0000 ++++ b/gopls/internal/label/keys.go 1970-01-01 00:00:00.000000000 +0000 +@@ -1,37 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - --//go:build go1.20 --// +build go1.20 +-// Package label provides common labels used to annotate gopls log messages +-// and events. +-package label - --package hooks +-import "golang.org/x/tools/internal/event/keys" - --import ( -- "golang.org/x/tools/gopls/internal/protocol" -- "golang.org/x/tools/gopls/internal/settings" -- "honnef.co/go/tools/analysis/lint" -- "honnef.co/go/tools/quickfix" -- "honnef.co/go/tools/simple" -- "honnef.co/go/tools/staticcheck" -- "honnef.co/go/tools/stylecheck" --) -- --func updateAnalyzers(options *settings.Options) { -- options.StaticcheckSupported = true -- -- mapSeverity := func(severity lint.Severity) protocol.DiagnosticSeverity { -- switch severity { -- case lint.SeverityError: -- return protocol.SeverityError -- case lint.SeverityDeprecated: -- // TODO(dh): in LSP, deprecated is a tag, not a severity. -- // We'll want to support this once we enable SA5011. -- return protocol.SeverityWarning -- case lint.SeverityWarning: -- return protocol.SeverityWarning -- case lint.SeverityInfo: -- return protocol.SeverityInformation -- case lint.SeverityHint: -- return protocol.SeverityHint -- default: -- return protocol.SeverityWarning -- } -- } -- add := func(analyzers []*lint.Analyzer, skip map[string]struct{}) { -- for _, a := range analyzers { -- if _, ok := skip[a.Analyzer.Name]; ok { -- continue -- } -- -- enabled := !a.Doc.NonDefault -- options.AddStaticcheckAnalyzer(a.Analyzer, enabled, mapSeverity(a.Doc.Severity)) -- } -- } -- -- add(simple.Analyzers, nil) -- add(staticcheck.Analyzers, map[string]struct{}{ -- // This check conflicts with the vet printf check (golang/go#34494). -- "SA5009": {}, -- // This check relies on facts from dependencies, which -- // we don't currently compute. -- "SA5011": {}, -- }) -- add(stylecheck.Analyzers, nil) -- add(quickfix.Analyzers, nil) --} -diff -urN a/gopls/internal/hooks/gen-licenses.sh b/gopls/internal/hooks/gen-licenses.sh ---- a/gopls/internal/hooks/gen-licenses.sh 2000-01-01 00:00:00.000000000 -0000 -+++ b/gopls/internal/hooks/gen-licenses.sh 1970-01-01 00:00:00.000000000 +0000 +-var ( +- File = keys.NewString("file", "") +- Directory = keys.New("directory", "") +- URI = keys.New("URI", "") +- Package = keys.NewString("package", "") // sorted comma-separated list of Package IDs +- Query = keys.New("query", "") +- ViewID = keys.NewString("view_id", "") +- Snapshot = keys.NewUInt64("snapshot", "") +- Operation = keys.NewString("operation", "") +- Duration = keys.New("duration", "Elapsed time") +- +- Position = keys.New("position", "") +- PackageCount = keys.NewInt("packages", "") +- Files = keys.New("files", "") +- Port = keys.NewInt("port", "") +- +- NewServer = keys.NewString("new_server", "A new server was added") +- EndServer = keys.NewString("end_server", "A server was shut down") +- +- ServerID = keys.NewString("server", "The server ID an event is related to") +- Logfile = keys.NewString("logfile", "") +- DebugAddress = keys.NewString("debug_address", "") +- GoplsPath = keys.NewString("gopls_path", "") +- ClientID = keys.NewString("client_id", "") +- +- Level = keys.NewInt("level", "The logging level") +-) +diff -urN a/gopls/internal/licenses/gen-licenses.sh b/gopls/internal/licenses/gen-licenses.sh +--- a/gopls/internal/licenses/gen-licenses.sh 2000-01-01 00:00:00.000000000 -0000 ++++ b/gopls/internal/licenses/gen-licenses.sh 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -#!/bin/bash -eu - @@ -67532,9 +68045,9 @@ diff -urN a/gopls/internal/hooks/gen-licenses.sh b/gopls/internal/hooks/gen-lice -// license that can be found in the LICENSE file. - -//go:generate ./gen-licenses.sh licenses.go --package hooks +-package licenses - --const licensesText = \` +-const Text = \` -END - -# List all the modules gopls depends on, except other golang.org modules, which @@ -67552,199 +68065,18 @@ diff -urN a/gopls/internal/hooks/gen-licenses.sh b/gopls/internal/hooks/gen-lice - -echo "\`" >> $tempfile -mv $tempfile $output -\ No newline at end of file -diff -urN a/gopls/internal/hooks/gofumpt_119.go b/gopls/internal/hooks/gofumpt_119.go ---- a/gopls/internal/hooks/gofumpt_119.go 2000-01-01 00:00:00.000000000 -0000 -+++ b/gopls/internal/hooks/gofumpt_119.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,13 +0,0 @@ --// Copyright 2021 The Go Authors. All rights reserved. --// Use of this source code is governed by a BSD-style --// license that can be found in the LICENSE file. -- --//go:build !go1.20 --// +build !go1.20 -- --package hooks -- --import "golang.org/x/tools/gopls/internal/settings" -- --func updateGofumpt(options *settings.Options) { --} -diff -urN a/gopls/internal/hooks/gofumpt_120.go b/gopls/internal/hooks/gofumpt_120.go ---- a/gopls/internal/hooks/gofumpt_120.go 2000-01-01 00:00:00.000000000 -0000 -+++ b/gopls/internal/hooks/gofumpt_120.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,78 +0,0 @@ --// Copyright 2022 The Go Authors. All rights reserved. --// Use of this source code is governed by a BSD-style --// license that can be found in the LICENSE file. -- --//go:build go1.20 --// +build go1.20 -- --package hooks -- --import ( -- "context" -- "fmt" -- -- "golang.org/x/tools/gopls/internal/settings" -- "mvdan.cc/gofumpt/format" --) -- --func updateGofumpt(options *settings.Options) { -- options.GofumptFormat = func(ctx context.Context, langVersion, modulePath string, src []byte) ([]byte, error) { -- fixedVersion, err := fixLangVersion(langVersion) -- if err != nil { -- return nil, err -- } -- return format.Source(src, format.Options{ -- LangVersion: fixedVersion, -- ModulePath: modulePath, -- }) -- } --} -- --// fixLangVersion function cleans the input so that gofumpt doesn't panic. It is --// rather permissive, and accepts version strings that aren't technically valid --// in a go.mod file. --// --// More specifically, it looks for an optional 'v' followed by 1-3 --// '.'-separated numbers. The resulting string is stripped of any suffix beyond --// this expected version number pattern. --// --// See also golang/go#61692: gofumpt does not accept the new language versions --// appearing in go.mod files (e.g. go1.21rc3). --func fixLangVersion(input string) (string, error) { -- bad := func() (string, error) { -- return "", fmt.Errorf("invalid language version syntax %q", input) -- } -- if input == "" { -- return input, nil -- } -- i := 0 -- if input[0] == 'v' { // be flexible about 'v' -- i++ -- } -- // takeDigits consumes ascii numerals 0-9 and reports if at least one was -- // consumed. -- takeDigits := func() bool { -- found := false -- for ; i < len(input) && '0' <= input[i] && input[i] <= '9'; i++ { -- found = true -- } -- return found -- } -- if !takeDigits() { // versions must start with at least one number -- return bad() -- } -- -- // Accept optional minor and patch versions. -- for n := 0; n < 2; n++ { -- if i < len(input) && input[i] == '.' { -- // Look for minor/patch version. -- i++ -- if !takeDigits() { -- i-- -- break -- } -- } -- } -- // Accept any suffix. -- return input[:i], nil --} -diff -urN a/gopls/internal/hooks/gofumpt_120_test.go b/gopls/internal/hooks/gofumpt_120_test.go ---- a/gopls/internal/hooks/gofumpt_120_test.go 2000-01-01 00:00:00.000000000 -0000 -+++ b/gopls/internal/hooks/gofumpt_120_test.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,53 +0,0 @@ --// Copyright 2022 The Go Authors. All rights reserved. --// Use of this source code is governed by a BSD-style --// license that can be found in the LICENSE file. -- --//go:build go1.20 --// +build go1.20 -- --package hooks -- --import "testing" -- --func TestFixLangVersion(t *testing.T) { -- tests := []struct { -- input, want string -- wantErr bool -- }{ -- {"", "", false}, -- {"1.18", "1.18", false}, -- {"v1.18", "v1.18", false}, -- {"1.21", "1.21", false}, -- {"1.21rc3", "1.21", false}, -- {"1.21.0", "1.21.0", false}, -- {"1.21.1", "1.21.1", false}, -- {"v1.21.1", "v1.21.1", false}, -- {"v1.21.0rc1", "v1.21.0", false}, // not technically valid, but we're flexible -- {"v1.21.0.0", "v1.21.0", false}, // also technically invalid -- {"1.1", "1.1", false}, -- {"v1", "v1", false}, -- {"1", "1", false}, -- {"v1.21.", "v1.21", false}, // also invalid -- {"1.21.", "1.21", false}, -- -- // Error cases. -- {"rc1", "", true}, -- {"x1.2.3", "", true}, -- } -- -- for _, test := range tests { -- got, err := fixLangVersion(test.input) -- if test.wantErr { -- if err == nil { -- t.Errorf("fixLangVersion(%q) succeeded unexpectedly", test.input) -- } -- continue -- } -- if err != nil { -- t.Fatalf("fixLangVersion(%q) failed: %v", test.input, err) -- } -- if got != test.want { -- t.Errorf("fixLangVersion(%q) = %s, want %s", test.input, got, test.want) -- } -- } --} -diff -urN a/gopls/internal/hooks/hooks.go b/gopls/internal/hooks/hooks.go ---- a/gopls/internal/hooks/hooks.go 2000-01-01 00:00:00.000000000 -0000 -+++ b/gopls/internal/hooks/hooks.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,20 +0,0 @@ --// Copyright 2019 The Go Authors. All rights reserved. --// Use of this source code is governed by a BSD-style --// license that can be found in the LICENSE file. -- --// Package hooks adds all the standard gopls implementations. --// This can be used in tests without needing to use the gopls main, and is --// also the place to edit for custom builds of gopls. --package hooks // import "golang.org/x/tools/gopls/internal/hooks" -- --import ( -- "golang.org/x/tools/gopls/internal/settings" -- "mvdan.cc/xurls/v2" --) -- --func Options(options *settings.Options) { -- options.LicensesText = licensesText -- options.URLRegexp = xurls.Relaxed() -- updateAnalyzers(options) -- updateGofumpt(options) --} -diff -urN a/gopls/internal/hooks/licenses.go b/gopls/internal/hooks/licenses.go ---- a/gopls/internal/hooks/licenses.go 2000-01-01 00:00:00.000000000 -0000 -+++ b/gopls/internal/hooks/licenses.go 1970-01-01 00:00:00.000000000 +0000 +diff -urN a/gopls/internal/licenses/licenses.go b/gopls/internal/licenses/licenses.go +--- a/gopls/internal/licenses/licenses.go 2000-01-01 00:00:00.000000000 -0000 ++++ b/gopls/internal/licenses/licenses.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,146 +0,0 @@ -// Copyright 2020 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:generate ./gen-licenses.sh licenses.go --package hooks +-package licenses - --const licensesText = ` +-const Text = ` --- github.com/BurntSushi/toml COPYING -- - -The MIT License (MIT) @@ -67883,15 +68215,15 @@ diff -urN a/gopls/internal/hooks/licenses.go b/gopls/internal/hooks/licenses.go -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -` -diff -urN a/gopls/internal/hooks/licenses_test.go b/gopls/internal/hooks/licenses_test.go ---- a/gopls/internal/hooks/licenses_test.go 2000-01-01 00:00:00.000000000 -0000 -+++ b/gopls/internal/hooks/licenses_test.go 1970-01-01 00:00:00.000000000 +0000 +diff -urN a/gopls/internal/licenses/licenses_test.go b/gopls/internal/licenses/licenses_test.go +--- a/gopls/internal/licenses/licenses_test.go 2000-01-01 00:00:00.000000000 -0000 ++++ b/gopls/internal/licenses/licenses_test.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -// Copyright 2020 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - --package hooks +-package licenses_test - -import ( - "bytes" @@ -67931,7 +68263,7 @@ diff -urN a/gopls/internal/hooks/licenses_test.go b/gopls/internal/hooks/license - t.Fatal(err) - } - if !bytes.Equal(got, want) { -- t.Error("combined license text needs updating. Run: `go generate ./internal/hooks` from the gopls module.") +- t.Error("combined license text needs updating. Run: `go generate ./internal/licenses` from the gopls module.") - } -} diff -urN a/gopls/internal/lsprpc/autostart_default.go b/gopls/internal/lsprpc/autostart_default.go @@ -68819,12 +69151,12 @@ diff -urN a/gopls/internal/lsprpc/lsprpc.go b/gopls/internal/lsprpc/lsprpc.go - - "golang.org/x/tools/gopls/internal/cache" - "golang.org/x/tools/gopls/internal/debug" +- "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/protocol/command" - "golang.org/x/tools/gopls/internal/server" - "golang.org/x/tools/gopls/internal/settings" - "golang.org/x/tools/internal/event" -- "golang.org/x/tools/internal/event/tag" - "golang.org/x/tools/internal/jsonrpc2" -) - @@ -69057,11 +69389,11 @@ diff -urN a/gopls/internal/lsprpc/lsprpc.go b/gopls/internal/lsprpc/lsprpc.go - event.Error(ctx, "", fmt.Errorf("forwarder: gopls path mismatch: forwarder is %q, remote is %q", goplsPath, hresp.GoplsPath)) - } - event.Log(ctx, "New server", -- tag.NewServer.Of(f.serverID), -- tag.Logfile.Of(hresp.Logfile), -- tag.DebugAddress.Of(hresp.DebugAddr), -- tag.GoplsPath.Of(hresp.GoplsPath), -- tag.ClientID.Of(hresp.SessionID), +- label.NewServer.Of(f.serverID), +- label.Logfile.Of(hresp.Logfile), +- label.DebugAddress.Of(hresp.DebugAddr), +- label.GoplsPath.Of(hresp.GoplsPath), +- label.ClientID.Of(hresp.SessionID), - ) -} - @@ -69271,10 +69603,10 @@ diff -urN a/gopls/internal/lsprpc/lsprpc.go b/gopls/internal/lsprpc/lsprpc.go - } - event.Log(ctx, "Handshake session update", - cache.KeyUpdateSession.Of(session), -- tag.DebugAddress.Of(req.DebugAddr), -- tag.Logfile.Of(req.Logfile), -- tag.ServerID.Of(req.ServerID), -- tag.GoplsPath.Of(req.GoplsPath), +- label.DebugAddress.Of(req.DebugAddr), +- label.Logfile.Of(req.Logfile), +- label.ServerID.Of(req.ServerID), +- label.GoplsPath.Of(req.GoplsPath), - ) - resp := handshakeResponse{ - SessionID: session.ID(), @@ -70136,7 +70468,7 @@ diff -urN a/gopls/internal/mod/code_lens.go b/gopls/internal/mod/code_lens.go diff -urN a/gopls/internal/mod/diagnostics.go b/gopls/internal/mod/diagnostics.go --- a/gopls/internal/mod/diagnostics.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/mod/diagnostics.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,560 +0,0 @@ +@@ -1,564 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -70254,12 +70586,16 @@ diff -urN a/gopls/internal/mod/diagnostics.go b/gopls/internal/mod/diagnostics.g - - tidied, err := snapshot.ModTidy(ctx, pm) - if err != nil { -- if err != cache.ErrNoModOnDisk { +- if err != cache.ErrNoModOnDisk && !strings.Contains(err.Error(), "GOPROXY=off") { - // TODO(rfindley): the check for ErrNoModOnDisk was historically determined - // to be benign, but may date back to the time when the Go command did not - // have overlay support. - // - // See if we can pass the overlay to the Go command, and eliminate this guard.. +- +- // TODO(golang/go#56395): remove the arbitrary suppression of the mod +- // tidy error when GOPROXY=off. The true fix for this noisy log message +- // is to fix the mod tidy diagnostics. - event.Error(ctx, fmt.Sprintf("tidy: diagnosing %s", pm.URI), err) - } - return nil, nil @@ -71247,9 +71583,9 @@ diff -urN a/gopls/internal/progress/progress.go b/gopls/internal/progress/progre - "strings" - "sync" - +- "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/internal/event" -- "golang.org/x/tools/internal/event/tag" - "golang.org/x/tools/internal/xcontext" -) - @@ -71498,7 +71834,7 @@ diff -urN a/gopls/internal/progress/progress.go b/gopls/internal/progress/progre -} - -func (ew *eventWriter) Write(p []byte) (n int, err error) { -- event.Log(ew.ctx, string(p), tag.Operation.Of(ew.operation)) +- event.Log(ew.ctx, string(p), label.Operation.Of(ew.operation)) - return len(p), nil -} - @@ -72868,7 +73204,7 @@ diff -urN a/gopls/internal/protocol/command/generate.go b/gopls/internal/protoco diff -urN a/gopls/internal/protocol/command/interface.go b/gopls/internal/protocol/command/interface.go --- a/gopls/internal/protocol/command/interface.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/protocol/command/interface.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,534 +0,0 @@ +@@ -1,535 +0,0 @@ -// Copyright 2021 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -73398,6 +73734,7 @@ diff -urN a/gopls/internal/protocol/command/interface.go b/gopls/internal/protoc - -// A View holds summary information about a cache.View. -type View struct { +- ID string // view ID (the index of this view among all views created) - Type string // view type (via cache.ViewType.String) - Root protocol.DocumentURI // root dir of the view (e.g. containing go.mod or go.work) - Folder protocol.DocumentURI // workspace folder associated with the view @@ -74033,7 +74370,7 @@ diff -urN a/gopls/internal/protocol/generate/generate.go b/gopls/internal/protoc diff -urN a/gopls/internal/protocol/generate/main.go b/gopls/internal/protocol/generate/main.go --- a/gopls/internal/protocol/generate/main.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/protocol/generate/main.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,377 +0,0 @@ +@@ -1,360 +0,0 @@ -// Copyright 2022 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -74063,7 +74400,8 @@ diff -urN a/gopls/internal/protocol/generate/main.go b/gopls/internal/protocol/g - -// lspGitRef names a branch or tag in vscodeRepo. -// It implicitly determines the protocol version of the LSP used by gopls. --// For example, tag release/protocol/3.17.3 of the repo defines protocol version 3.17.0. +-// For example, tag release/protocol/3.17.3 of the repo defines +-// protocol version 3.17.0 (as declared by the metaData.version field). -// (Point releases are reflected in the git tag version even when they are cosmetic -// and don't change the protocol.) -var lspGitRef = "release/protocol/3.17.6-next.2" @@ -74152,16 +74490,7 @@ diff -urN a/gopls/internal/protocol/generate/main.go b/gopls/internal/protocol/g - for _, k := range cfuncs.keys() { - out.WriteString(cfuncs[k]) - } -- -- x, err := format.Source(out.Bytes()) -- if err != nil { -- os.WriteFile("/tmp/a.go", out.Bytes(), 0644) -- log.Fatalf("tsclient.go: %v", err) -- } -- -- if err := os.WriteFile(filepath.Join(*outputdir, "tsclient.go"), x, 0644); err != nil { -- log.Fatalf("%v writing tsclient.go", err) -- } +- formatTo("tsclient.go", out.Bytes()) -} - -func writeserver() { @@ -74192,15 +74521,7 @@ diff -urN a/gopls/internal/protocol/generate/main.go b/gopls/internal/protocol/g - for _, k := range sfuncs.keys() { - out.WriteString(sfuncs[k]) - } -- x, err := format.Source(out.Bytes()) -- if err != nil { -- os.WriteFile("/tmp/a.go", out.Bytes(), 0644) -- log.Fatalf("tsserver.go: %v", err) -- } -- -- if err := os.WriteFile(filepath.Join(*outputdir, "tsserver.go"), x, 0644); err != nil { -- log.Fatalf("%v writing tsserver.go", err) -- } +- formatTo("tsserver.go", out.Bytes()) -} - -func writeprotocol() { @@ -74208,7 +74529,7 @@ diff -urN a/gopls/internal/protocol/generate/main.go b/gopls/internal/protocol/g - fmt.Fprintln(out, fileHdr) - out.WriteString("import \"encoding/json\"\n\n") - -- // The followiing are unneeded, but make the new code a superset of the old +- // The following are unneeded, but make the new code a superset of the old - hack := func(newer, existing string) { - if _, ok := types[existing]; !ok { - log.Fatalf("types[%q] not found", existing) @@ -74233,14 +74554,7 @@ diff -urN a/gopls/internal/protocol/generate/main.go b/gopls/internal/protocol/g - out.WriteString(consts[k]) - } - out.WriteString(")\n\n") -- x, err := format.Source(out.Bytes()) -- if err != nil { -- os.WriteFile("/tmp/a.go", out.Bytes(), 0644) -- log.Fatalf("tsprotocol.go: %v", err) -- } -- if err := os.WriteFile(filepath.Join(*outputdir, "tsprotocol.go"), x, 0644); err != nil { -- log.Fatalf("%v writing tsprotocol.go", err) -- } +- formatTo("tsprotocol.go", out.Bytes()) -} - -func writejsons() { @@ -74264,18 +74578,24 @@ diff -urN a/gopls/internal/protocol/generate/main.go b/gopls/internal/protocol/g - for _, k := range jsons.keys() { - out.WriteString(jsons[k]) - } -- x, err := format.Source(out.Bytes()) +- formatTo("tsjson.go", out.Bytes()) +-} +- +-// formatTo formats the Go source and writes it to *outputdir/basename. +-func formatTo(basename string, src []byte) { +- formatted, err := format.Source(src) - if err != nil { -- os.WriteFile("/tmp/a.go", out.Bytes(), 0644) -- log.Fatalf("tsjson.go: %v", err) +- failed := filepath.Join("/tmp", basename+".fail") +- os.WriteFile(failed, src, 0644) +- log.Fatalf("formatting %s: %v (see %s)", basename, err, failed) - } -- if err := os.WriteFile(filepath.Join(*outputdir, "tsjson.go"), x, 0644); err != nil { -- log.Fatalf("%v writing tsjson.go", err) +- if err := os.WriteFile(filepath.Join(*outputdir, basename), formatted, 0644); err != nil { +- log.Fatal(err) - } -} - -// create the common file header for the output files --func fileHeader(model Model) string { +-func fileHeader(model *Model) string { - fname := filepath.Join(*repodir, ".git", "HEAD") - buf, err := os.ReadFile(fname) - if err != nil { @@ -74317,14 +74637,14 @@ diff -urN a/gopls/internal/protocol/generate/main.go b/gopls/internal/protocol/g - model.Version.Version) // 5 -} - --func parse(fname string) Model { +-func parse(fname string) *Model { - buf, err := os.ReadFile(fname) - if err != nil { - log.Fatal(err) - } - buf = addLineNumbers(buf) -- var model Model -- if err := json.Unmarshal(buf, &model); err != nil { +- model := new(Model) +- if err := json.Unmarshal(buf, model); err != nil { - log.Fatal(err) - } - return model @@ -74534,7 +74854,7 @@ diff -urN a/gopls/internal/protocol/generate/main_test.go b/gopls/internal/proto diff -urN a/gopls/internal/protocol/generate/output.go b/gopls/internal/protocol/generate/output.go --- a/gopls/internal/protocol/generate/output.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/protocol/generate/output.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,423 +0,0 @@ +@@ -1,441 +0,0 @@ -// Copyright 2022 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -74565,19 +74885,19 @@ diff -urN a/gopls/internal/protocol/generate/output.go b/gopls/internal/protocol - jsons = make(sortedMap[string]) -) - --func generateOutput(model Model) { +-func generateOutput(model *Model) { - for _, r := range model.Requests { -- genDecl(r.Method, r.Params, r.Result, r.Direction) -- genCase(r.Method, r.Params, r.Result, r.Direction) -- genFunc(r.Method, r.Params, r.Result, r.Direction, false) +- genDecl(model, r.Method, r.Params, r.Result, r.Direction) +- genCase(model, r.Method, r.Params, r.Result, r.Direction) +- genFunc(model, r.Method, r.Params, r.Result, r.Direction, false) - } - for _, n := range model.Notifications { - if n.Method == "$/cancelRequest" { - continue // handled internally by jsonrpc2 - } -- genDecl(n.Method, n.Params, nil, n.Direction) -- genCase(n.Method, n.Params, nil, n.Direction) -- genFunc(n.Method, n.Params, nil, n.Direction, true) +- genDecl(model, n.Method, n.Params, nil, n.Direction) +- genCase(model, n.Method, n.Params, nil, n.Direction) +- genFunc(model, n.Method, n.Params, nil, n.Direction, true) - } - genStructs(model) - genAliases(model) @@ -74586,7 +74906,7 @@ diff -urN a/gopls/internal/protocol/generate/output.go b/gopls/internal/protocol - genMarshal() -} - --func genDecl(method string, param, result *Type, dir string) { +-func genDecl(model *Model, method string, param, result *Type, dir string) { - fname := methodName(method) - p := "" - if notNil(param) { @@ -74608,7 +74928,8 @@ diff -urN a/gopls/internal/protocol/generate/output.go b/gopls/internal/protocol - p = ", *ParamConfiguration" - ret = "([]LSPAny, error)" - } -- msg := fmt.Sprintf("\t%s(context.Context%s) %s // %s\n", fname, p, ret, method) +- fragment := strings.ReplaceAll(strings.TrimPrefix(method, "$/"), "/", "_") +- msg := fmt.Sprintf("\t%s\t%s(context.Context%s) %s\n", lspLink(model, fragment), fname, p, ret) - switch dir { - case "clientToServer": - sdecls[method] = msg @@ -74622,7 +74943,7 @@ diff -urN a/gopls/internal/protocol/generate/output.go b/gopls/internal/protocol - } -} - --func genCase(method string, param, result *Type, dir string) { +-func genCase(model *Model, method string, param, result *Type, dir string) { - out := new(bytes.Buffer) - fmt.Fprintf(out, "\tcase %q:\n", method) - var p string @@ -74664,7 +74985,7 @@ diff -urN a/gopls/internal/protocol/generate/output.go b/gopls/internal/protocol - } -} - --func genFunc(method string, param, result *Type, dir string, isnotify bool) { +-func genFunc(model *Model, method string, param, result *Type, dir string, isnotify bool) { - out := new(bytes.Buffer) - var p, r string - var goResult string @@ -74739,7 +75060,7 @@ diff -urN a/gopls/internal/protocol/generate/output.go b/gopls/internal/protocol - } -} - --func genStructs(model Model) { +-func genStructs(model *Model) { - structures := make(map[string]*Structure) // for expanding Extends - for _, s := range model.Structures { - structures[s.Name] = s @@ -74752,6 +75073,8 @@ diff -urN a/gopls/internal/protocol/generate/output.go b/gopls/internal/protocol - // a weird case, and needed only so the generated code contains the old gopls code - nm = "DocumentDiagnosticParams" - } +- fmt.Fprintf(out, "//\n") +- out.WriteString(lspLink(model, camelCase(s.Name))) - fmt.Fprintf(out, "type %s struct {%s\n", nm, linex(s.Line)) - // for gpls compatibilitye, embed most extensions, but expand the rest some day - props := append([]NameType{}, s.Properties...) @@ -74782,6 +75105,19 @@ diff -urN a/gopls/internal/protocol/generate/output.go b/gopls/internal/protocol - -} - +-// "FooBar" -> "fooBar" +-func camelCase(TitleCased string) string { +- return strings.ToLower(TitleCased[:1]) + TitleCased[1:] +-} +- +-func lspLink(model *Model, fragment string) string { +- // Derive URL version from metaData.version in JSON file. +- parts := strings.Split(model.Version.Version, ".") // e.g. "3.17.0" +- return fmt.Sprintf("// See https://microsoft.github.io/language-server-protocol/specifications/lsp/%s.%s/specification#%s\n", +- parts[0], parts[1], // major.minor +- fragment) +-} +- -func genProps(out *bytes.Buffer, props []NameType, name string) { - for _, p := range props { - tp := goplsName(p.Type) @@ -74800,7 +75136,7 @@ diff -urN a/gopls/internal/protocol/generate/output.go b/gopls/internal/protocol - } -} - --func genAliases(model Model) { +-func genAliases(model *Model) { - for _, ta := range model.TypeAliases { - out := new(bytes.Buffer) - generateDoc(out, ta.Documentation) @@ -74809,6 +75145,8 @@ diff -urN a/gopls/internal/protocol/generate/output.go b/gopls/internal/protocol - continue // renamed the type, e.g., "DocumentDiagnosticReport", an or-type to "string" - } - tp := goplsName(ta.Type) +- fmt.Fprintf(out, "//\n") +- out.WriteString(lspLink(model, camelCase(ta.Name))) - fmt.Fprintf(out, "type %s = %s // (alias)\n", nm, tp) - types[nm] = out.String() - } @@ -74857,7 +75195,7 @@ diff -urN a/gopls/internal/protocol/generate/output.go b/gopls/internal/protocol - types[nm] = out.String() - } -} --func genConsts(model Model) { +-func genConsts(model *Model) { - for _, e := range model.Enumerations { - out := new(bytes.Buffer) - generateDoc(out, e.Documentation) @@ -75404,7 +75742,7 @@ diff -urN a/gopls/internal/protocol/generate/typenames.go b/gopls/internal/proto -var typeNames = make(map[*Type]string) -var genTypes []*newType - --func findTypeNames(model Model) { +-func findTypeNames(model *Model) { - for _, s := range model.Structures { - for _, e := range s.Extends { - nameType(e, nil) // all references @@ -77512,7 +77850,7 @@ diff -urN a/gopls/internal/protocol/span.go b/gopls/internal/protocol/span.go diff -urN a/gopls/internal/protocol/tsclient.go b/gopls/internal/protocol/tsclient.go --- a/gopls/internal/protocol/tsclient.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/protocol/tsclient.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,276 +0,0 @@ +@@ -1,296 +0,0 @@ -// Copyright 2023 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -77532,26 +77870,46 @@ diff -urN a/gopls/internal/protocol/tsclient.go b/gopls/internal/protocol/tsclie -) - -type Client interface { -- LogTrace(context.Context, *LogTraceParams) error // $/logTrace -- Progress(context.Context, *ProgressParams) error // $/progress -- RegisterCapability(context.Context, *RegistrationParams) error // client/registerCapability -- UnregisterCapability(context.Context, *UnregistrationParams) error // client/unregisterCapability -- Event(context.Context, *interface{}) error // telemetry/event -- PublishDiagnostics(context.Context, *PublishDiagnosticsParams) error // textDocument/publishDiagnostics -- LogMessage(context.Context, *LogMessageParams) error // window/logMessage -- ShowDocument(context.Context, *ShowDocumentParams) (*ShowDocumentResult, error) // window/showDocument -- ShowMessage(context.Context, *ShowMessageParams) error // window/showMessage -- ShowMessageRequest(context.Context, *ShowMessageRequestParams) (*MessageActionItem, error) // window/showMessageRequest -- WorkDoneProgressCreate(context.Context, *WorkDoneProgressCreateParams) error // window/workDoneProgress/create -- ApplyEdit(context.Context, *ApplyWorkspaceEditParams) (*ApplyWorkspaceEditResult, error) // workspace/applyEdit -- CodeLensRefresh(context.Context) error // workspace/codeLens/refresh -- Configuration(context.Context, *ParamConfiguration) ([]LSPAny, error) // workspace/configuration -- DiagnosticRefresh(context.Context) error // workspace/diagnostic/refresh -- FoldingRangeRefresh(context.Context) error // workspace/foldingRange/refresh -- InlayHintRefresh(context.Context) error // workspace/inlayHint/refresh -- InlineValueRefresh(context.Context) error // workspace/inlineValue/refresh -- SemanticTokensRefresh(context.Context) error // workspace/semanticTokens/refresh -- WorkspaceFolders(context.Context) ([]WorkspaceFolder, error) // workspace/workspaceFolders +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#logTrace +- LogTrace(context.Context, *LogTraceParams) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#progress +- Progress(context.Context, *ProgressParams) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#client_registerCapability +- RegisterCapability(context.Context, *RegistrationParams) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#client_unregisterCapability +- UnregisterCapability(context.Context, *UnregistrationParams) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#telemetry_event +- Event(context.Context, *interface{}) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_publishDiagnostics +- PublishDiagnostics(context.Context, *PublishDiagnosticsParams) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#window_logMessage +- LogMessage(context.Context, *LogMessageParams) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#window_showDocument +- ShowDocument(context.Context, *ShowDocumentParams) (*ShowDocumentResult, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#window_showMessage +- ShowMessage(context.Context, *ShowMessageParams) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#window_showMessageRequest +- ShowMessageRequest(context.Context, *ShowMessageRequestParams) (*MessageActionItem, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#window_workDoneProgress_create +- WorkDoneProgressCreate(context.Context, *WorkDoneProgressCreateParams) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_applyEdit +- ApplyEdit(context.Context, *ApplyWorkspaceEditParams) (*ApplyWorkspaceEditResult, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_codeLens_refresh +- CodeLensRefresh(context.Context) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_configuration +- Configuration(context.Context, *ParamConfiguration) ([]LSPAny, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_diagnostic_refresh +- DiagnosticRefresh(context.Context) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_foldingRange_refresh +- FoldingRangeRefresh(context.Context) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_inlayHint_refresh +- InlayHintRefresh(context.Context) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_inlineValue_refresh +- InlineValueRefresh(context.Context) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_semanticTokens_refresh +- SemanticTokensRefresh(context.Context) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_workspaceFolders +- WorkspaceFolders(context.Context) ([]WorkspaceFolder, error) -} - -func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, r jsonrpc2.Request) (bool, error) { @@ -79972,7 +80330,7 @@ diff -urN a/gopls/internal/protocol/tsjson.go b/gopls/internal/protocol/tsjson.g diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tsprotocol.go --- a/gopls/internal/protocol/tsprotocol.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/protocol/tsprotocol.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,5931 +0,0 @@ +@@ -1,6727 +0,0 @@ -// Copyright 2023 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -79990,6 +80348,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// A special text edit with an additional change annotation. -// -// @since 3.16.0. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#annotatedTextEdit -type AnnotatedTextEdit struct { - // The actual identifier of the change annotation - AnnotationID *ChangeAnnotationIdentifier `json:"annotationId,omitempty"` @@ -79997,6 +80357,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// The parameters passed via an apply workspace edit request. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#applyWorkspaceEditParams -type ApplyWorkspaceEditParams struct { - // An optional label of the workspace edit. This label is - // presented in the user interface for example on an undo @@ -80009,6 +80371,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// The result returned from the apply workspace edit request. -// -// @since 3.17 renamed from ApplyWorkspaceEditResponse +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#applyWorkspaceEditResult -type ApplyWorkspaceEditResult struct { - // Indicates whether the edit was applied or not. - Applied bool `json:"applied"` @@ -80023,6 +80387,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// A base for all symbol information. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#baseSymbolInformation -type BaseSymbolInformation struct { - // The name of this symbol. - Name string `json:"name"` @@ -80040,6 +80406,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#callHierarchyClientCapabilities -type CallHierarchyClientCapabilities struct { - // Whether implementation supports dynamic registration. If this is set to `true` - // the client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)` @@ -80050,6 +80418,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Represents an incoming call, e.g. a caller of a method or constructor. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#callHierarchyIncomingCall -type CallHierarchyIncomingCall struct { - // The item that makes the call. - From CallHierarchyItem `json:"from"` @@ -80061,6 +80431,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// The parameter of a `callHierarchy/incomingCalls` request. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#callHierarchyIncomingCallsParams -type CallHierarchyIncomingCallsParams struct { - Item CallHierarchyItem `json:"item"` - WorkDoneProgressParams @@ -80071,6 +80443,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// of call hierarchy. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#callHierarchyItem -type CallHierarchyItem struct { - // The name of this item. - Name string `json:"name"` @@ -80095,6 +80469,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Call hierarchy options used during static registration. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#callHierarchyOptions -type CallHierarchyOptions struct { - WorkDoneProgressOptions -} @@ -80102,6 +80478,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Represents an outgoing call, e.g. calling a getter from a method or a method from a constructor etc. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#callHierarchyOutgoingCall -type CallHierarchyOutgoingCall struct { - // The item that is called. - To CallHierarchyItem `json:"to"` @@ -80114,6 +80492,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// The parameter of a `callHierarchy/outgoingCalls` request. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#callHierarchyOutgoingCallsParams -type CallHierarchyOutgoingCallsParams struct { - Item CallHierarchyItem `json:"item"` - WorkDoneProgressParams @@ -80123,6 +80503,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// The parameter of a `textDocument/prepareCallHierarchy` request. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#callHierarchyPrepareParams -type CallHierarchyPrepareParams struct { - TextDocumentPositionParams - WorkDoneProgressParams @@ -80131,11 +80513,15 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Call hierarchy options used during static or dynamic registration. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#callHierarchyRegistrationOptions -type CallHierarchyRegistrationOptions struct { - TextDocumentRegistrationOptions - CallHierarchyOptions - StaticRegistrationOptions -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#cancelParams -type CancelParams struct { - // The request id to cancel. - ID interface{} `json:"id"` @@ -80144,6 +80530,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Additional information that describes document changes. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#changeAnnotation -type ChangeAnnotation struct { - // A human-readable string describing the actual change. The string - // is rendered prominent in the user interface. @@ -80157,9 +80545,13 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// An identifier to refer to a change annotation stored with a workspace edit. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#changeAnnotationIdentifier -type ChangeAnnotationIdentifier = string // (alias) -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#changeAnnotationsSupportOptions -type ChangeAnnotationsSupportOptions struct { - // Whether the client groups edits with equal labels into tree nodes, - // for instance all edits labelled with "Changes in Strings" would @@ -80168,6 +80560,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Defines the capabilities provided by the client. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientCapabilities -type ClientCapabilities struct { - // Workspace specific client capabilities. - Workspace WorkspaceClientCapabilities `json:"workspace,omitempty"` @@ -80189,6 +80583,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientCodeActionKindOptions -type ClientCodeActionKindOptions struct { - // The code action kind values the client supports. When this - // property exists the client also guarantees that it will @@ -80199,6 +80595,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientCodeActionLiteralOptions -type ClientCodeActionLiteralOptions struct { - // The code action kind is support with the following value - // set. @@ -80207,6 +80605,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientCodeActionResolveOptions -type ClientCodeActionResolveOptions struct { - // The properties that a client can resolve lazily. - Properties []string `json:"properties"` @@ -80214,12 +80614,16 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientCompletionItemInsertTextModeOptions -type ClientCompletionItemInsertTextModeOptions struct { - ValueSet []InsertTextMode `json:"valueSet"` -} - -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientCompletionItemOptions -type ClientCompletionItemOptions struct { - // Client supports snippets as insert text. - // @@ -80270,6 +80674,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientCompletionItemOptionsKind -type ClientCompletionItemOptionsKind struct { - // The completion item kind values the client supports. When this - // property exists the client also guarantees that it will @@ -80284,6 +80690,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientCompletionItemResolveOptions -type ClientCompletionItemResolveOptions struct { - // The properties that a client can resolve lazily. - Properties []string `json:"properties"` @@ -80291,6 +80699,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientDiagnosticsTagOptions -type ClientDiagnosticsTagOptions struct { - // The tags supported by the client. - ValueSet []DiagnosticTag `json:"valueSet"` @@ -80298,6 +80708,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientFoldingRangeKindOptions -type ClientFoldingRangeKindOptions struct { - // The folding range kind values the client supports. When this - // property exists the client also guarantees that it will @@ -80308,6 +80720,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientFoldingRangeOptions -type ClientFoldingRangeOptions struct { - // If set, the client signals that it supports setting collapsedText on - // folding ranges to display custom labels instead of the default text. @@ -80321,6 +80735,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// @since 3.15.0 -// @since 3.18.0 ClientInfo type name added. -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientInfo -type ClientInfo struct { - // The name of the client as defined by the client. - Name string `json:"name"` @@ -80330,6 +80746,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientInlayHintResolveOptions -type ClientInlayHintResolveOptions struct { - // The properties that a client can resolve lazily. - Properties []string `json:"properties"` @@ -80337,6 +80755,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientSemanticTokensRequestFullDelta -type ClientSemanticTokensRequestFullDelta struct { - // The client will send the `textDocument/semanticTokens/full/delta` request if - // the server provides a corresponding handler. @@ -80345,6 +80765,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientSemanticTokensRequestOptions -type ClientSemanticTokensRequestOptions struct { - // The client will send the `textDocument/semanticTokens/range` request if - // the server provides a corresponding handler. @@ -80356,6 +80778,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientShowMessageActionItemOptions -type ClientShowMessageActionItemOptions struct { - // Whether the client supports additional attributes which - // are preserved and send back to the server in the @@ -80365,6 +80789,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientSignatureInformationOptions -type ClientSignatureInformationOptions struct { - // Client supports the following content formats for the documentation - // property. The order describes the preferred format of the client. @@ -80387,6 +80813,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientSignatureParameterInformationOptions -type ClientSignatureParameterInformationOptions struct { - // The client supports processing label offsets instead of a - // simple label string. @@ -80397,6 +80825,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientSymbolKindOptions -type ClientSymbolKindOptions struct { - // The symbol kind values the client supports. When this - // property exists the client also guarantees that it will @@ -80411,6 +80841,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientSymbolResolveOptions -type ClientSymbolResolveOptions struct { - // The properties that a client can resolve lazily. Usually - // `location.range` @@ -80419,6 +80851,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientSymbolTagOptions -type ClientSymbolTagOptions struct { - // The tags supported by the client. - ValueSet []SymbolTag `json:"valueSet"` @@ -80428,6 +80862,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// to refactor code. -// -// A CodeAction must set either `edit` and/or a `command`. If both are supplied, the `edit` is applied first, then the `command` is executed. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeAction -type CodeAction struct { - // A short, human-readable, title for this code action. - Title string `json:"title"` @@ -80475,6 +80911,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// The Client Capabilities of a {@link CodeActionRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeActionClientCapabilities -type CodeActionClientCapabilities struct { - // Whether code action supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -80521,6 +80959,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// Contains additional diagnostic information about the context in which -// a {@link CodeActionProvider.provideCodeActions code action} is run. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeActionContext -type CodeActionContext struct { - // An array of diagnostics known on the client side overlapping the range provided to the - // `textDocument/codeAction` request. They are provided so that the server knows which @@ -80543,6 +80983,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeActionDisabled -type CodeActionDisabled struct { - // Human readable description of why the code action is currently disabled. - // @@ -80557,6 +80999,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeActionKindDocumentation -type CodeActionKindDocumentation struct { - // The kind of the code action being documented. - // @@ -80571,6 +81015,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Provider options for a {@link CodeActionRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeActionOptions -type CodeActionOptions struct { - // CodeActionKinds that this server may return. - // @@ -80604,6 +81050,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// The parameters of a {@link CodeActionRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeActionParams -type CodeActionParams struct { - // The document in which the command was invoked. - TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -80616,6 +81064,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Registration options for a {@link CodeActionRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeActionRegistrationOptions -type CodeActionRegistrationOptions struct { - TextDocumentRegistrationOptions - CodeActionOptions @@ -80629,6 +81079,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Structure to capture a description for an error code. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeDescription -type CodeDescription struct { - // An URI to open with more information about the diagnostic error. - Href URI `json:"href"` @@ -80639,6 +81091,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// A code lens is _unresolved_ when no command is associated to it. For performance -// reasons the creation of a code lens and resolving should be done in two stages. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeLens -type CodeLens struct { - // The range in which this code lens is valid. Should only span a single line. - Range Range `json:"range"` @@ -80650,12 +81104,16 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// The client capabilities of a {@link CodeLensRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeLensClientCapabilities -type CodeLensClientCapabilities struct { - // Whether code lens supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` -} - -// Code Lens provider options of a {@link CodeLensRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeLensOptions -type CodeLensOptions struct { - // Code lens has a resolve provider as well. - ResolveProvider bool `json:"resolveProvider,omitempty"` @@ -80663,6 +81121,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// The parameters of a {@link CodeLensRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeLensParams -type CodeLensParams struct { - // The document to request code lens for. - TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -80671,12 +81131,16 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Registration options for a {@link CodeLensRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeLensRegistrationOptions -type CodeLensRegistrationOptions struct { - TextDocumentRegistrationOptions - CodeLensOptions -} - -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeLensWorkspaceClientCapabilities -type CodeLensWorkspaceClientCapabilities struct { - // Whether the client implementation supports a refresh request sent from the - // server to the client. @@ -80689,6 +81153,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Represents a color in RGBA space. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#color -type Color struct { - // The red component of this color in the range [0-1]. - Red float64 `json:"red"` @@ -80701,12 +81167,16 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Represents a color range from a document. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#colorInformation -type ColorInformation struct { - // The range in the document where this color appears. - Range Range `json:"range"` - // The actual color value for this color range. - Color Color `json:"color"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#colorPresentation -type ColorPresentation struct { - // The label of this color presentation. It will be shown on the color - // picker header. By default this is also the text that is inserted when selecting @@ -80722,6 +81192,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Parameters for a {@link ColorPresentationRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#colorPresentationParams -type ColorPresentationParams struct { - // The text document. - TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -80737,6 +81209,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// will be used to represent a command in the UI and, optionally, -// an array of arguments which will be passed to the command handler -// function when invoked. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#command -type Command struct { - // Title of the command, like `save`. - Title string `json:"title"` @@ -80753,6 +81227,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Completion client capabilities +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#completionClientCapabilities -type CompletionClientCapabilities struct { - // Whether completion supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -80777,6 +81253,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Contains additional information about the context in which a completion request is triggered. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#completionContext -type CompletionContext struct { - // How the completion was triggered. - TriggerKind CompletionTriggerKind `json:"triggerKind"` @@ -80787,6 +81265,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// A completion item represents a text snippet that is -// proposed to complete text that is being typed. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#completionItem -type CompletionItem struct { - // The label of this completion item. - // @@ -80920,6 +81400,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// capability. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#completionItemDefaults -type CompletionItemDefaults struct { - // A default commit character set. - // @@ -80949,6 +81431,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Additional details for a completion item label. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#completionItemLabelDetails -type CompletionItemLabelDetails struct { - // An optional string which is rendered less prominently directly after {@link CompletionItem.label label}, - // without any spacing. Should be used for function signatures and type annotations. @@ -80966,6 +81450,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#completionItemTagOptions -type CompletionItemTagOptions struct { - // The tags supported by the client. - ValueSet []CompletionItemTag `json:"valueSet"` @@ -80973,6 +81459,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// Represents a collection of {@link CompletionItem completion items} to be presented -// in the editor. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#completionList -type CompletionList struct { - // This list it not complete. Further typing results in recomputing this list. - // @@ -81001,6 +81489,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// capabilities. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#completionListCapabilities -type CompletionListCapabilities struct { - // The client supports the following itemDefaults on - // a completion list. @@ -81014,6 +81504,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Completion options. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#completionOptions -type CompletionOptions struct { - // Most tools trigger completion request automatically without explicitly requesting - // it using a keyboard shortcut (e.g. Ctrl+Space). Typically they do so when the user @@ -81045,6 +81537,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Completion parameters +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#completionParams -type CompletionParams struct { - // The completion context. This is only available it the client specifies - // to send this using the client capability `textDocument.completion.contextSupport === true` @@ -81055,6 +81549,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Registration options for a {@link CompletionRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#completionRegistrationOptions -type CompletionRegistrationOptions struct { - TextDocumentRegistrationOptions - CompletionOptions @@ -81062,6 +81558,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// How a completion was triggered -type CompletionTriggerKind uint32 +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#configurationItem -type ConfigurationItem struct { - // The scope to get the configuration section for. - ScopeURI *URI `json:"scopeUri,omitempty"` @@ -81070,11 +81568,15 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// The parameters of a configuration request. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#configurationParams -type ConfigurationParams struct { - Items []ConfigurationItem `json:"items"` -} - -// Create file operation. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#createFile -type CreateFile struct { - // A create - Kind string `json:"kind"` @@ -81086,6 +81588,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Options to create a file. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#createFileOptions -type CreateFileOptions struct { - // Overwrite existing file. Overwrite wins over `ignoreIfExists` - Overwrite bool `json:"overwrite,omitempty"` @@ -81097,14 +81601,20 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// files. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#createFilesParams -type CreateFilesParams struct { - // An array of all files/folders created in this operation. - Files []FileCreate `json:"files"` -} - -// The declaration of a symbol representation as one or many {@link Location locations}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#declaration -type Declaration = []Location // (alias) -// @since 3.14.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#declarationClientCapabilities -type DeclarationClientCapabilities struct { - // Whether declaration supports dynamic registration. If this is set to `true` - // the client supports the new `DeclarationRegistrationOptions` return value @@ -81121,15 +81631,22 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// Servers should prefer returning `DeclarationLink` over `Declaration` if supported -// by the client. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#declarationLink -type DeclarationLink = LocationLink // (alias) +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#declarationOptions -type DeclarationOptions struct { - WorkDoneProgressOptions -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#declarationParams -type DeclarationParams struct { - TextDocumentPositionParams - WorkDoneProgressParams - PartialResultParams -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#declarationRegistrationOptions -type DeclarationRegistrationOptions struct { - DeclarationOptions - TextDocumentRegistrationOptions @@ -81142,8 +81659,12 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// Servers should prefer returning `DefinitionLink` over `Definition` if supported -// by the client. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#definition -type Definition = Or_Definition // (alias) -// Client Capabilities for a {@link DefinitionRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#definitionClientCapabilities -type DefinitionClientCapabilities struct { - // Whether definition supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -81157,13 +81678,19 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// Provides additional metadata over normal {@link Location location} definitions, including the range of -// the defining symbol +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#definitionLink -type DefinitionLink = LocationLink // (alias) -// Server Capabilities for a {@link DefinitionRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#definitionOptions -type DefinitionOptions struct { - WorkDoneProgressOptions -} - -// Parameters for a {@link DefinitionRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#definitionParams -type DefinitionParams struct { - TextDocumentPositionParams - WorkDoneProgressParams @@ -81171,12 +81698,16 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Registration options for a {@link DefinitionRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#definitionRegistrationOptions -type DefinitionRegistrationOptions struct { - TextDocumentRegistrationOptions - DefinitionOptions -} - -// Delete file operation +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#deleteFile -type DeleteFile struct { - // A delete - Kind string `json:"kind"` @@ -81188,6 +81719,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Delete file options +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#deleteFileOptions -type DeleteFileOptions struct { - // Delete the content recursively if a folder is denoted. - Recursive bool `json:"recursive,omitempty"` @@ -81199,6 +81732,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// files. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#deleteFilesParams -type DeleteFilesParams struct { - // An array of all files/folders deleted in this operation. - Files []FileDelete `json:"files"` @@ -81206,6 +81741,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// Represents a diagnostic, such as a compiler error or warning. Diagnostic objects -// are only valid in the scope of a resource. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#diagnostic -type Diagnostic struct { - // The range at which the message applies - Range Range `json:"range"` @@ -81242,6 +81779,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Client capabilities specific to diagnostic pull requests. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#diagnosticClientCapabilities -type DiagnosticClientCapabilities struct { - // Whether implementation supports dynamic registration. If this is set to `true` - // the client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)` @@ -81254,6 +81793,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Diagnostic options. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#diagnosticOptions -type DiagnosticOptions struct { - // An optional identifier under which the diagnostics are - // managed by the client. @@ -81271,6 +81812,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Diagnostic registration options. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#diagnosticRegistrationOptions -type DiagnosticRegistrationOptions struct { - TextDocumentRegistrationOptions - DiagnosticOptions @@ -81280,6 +81823,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Represents a related message and source code location for a diagnostic. This should be -// used to point to code locations that cause or related to a diagnostics, e.g when duplicating -// a symbol in a scope. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#diagnosticRelatedInformation -type DiagnosticRelatedInformation struct { - // The location of this related diagnostic information. - Location Location `json:"location"` @@ -81290,6 +81835,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Cancellation data returned from a diagnostic request. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#diagnosticServerCancellationData -type DiagnosticServerCancellationData struct { - RetriggerRequest bool `json:"retriggerRequest"` -} @@ -81305,6 +81852,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Workspace client capabilities specific to diagnostic pull requests. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#diagnosticWorkspaceClientCapabilities -type DiagnosticWorkspaceClientCapabilities struct { - // Whether the client implementation supports a refresh request sent from - // the server to the client. @@ -81315,16 +81864,22 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - // change that requires such a calculation. - RefreshSupport bool `json:"refreshSupport,omitempty"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#didChangeConfigurationClientCapabilities -type DidChangeConfigurationClientCapabilities struct { - // Did change configuration notification supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` -} - -// The parameters of a change configuration notification. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#didChangeConfigurationParams -type DidChangeConfigurationParams struct { - // The actual changed settings - Settings interface{} `json:"settings"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#didChangeConfigurationRegistrationOptions -type DidChangeConfigurationRegistrationOptions struct { - Section *OrPSection_workspace_didChangeConfiguration `json:"section,omitempty"` -} @@ -81332,6 +81887,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// The params sent in a change notebook document notification. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#didChangeNotebookDocumentParams -type DidChangeNotebookDocumentParams struct { - // The notebook document that did change. The version number points - // to the version after all provided changes have been applied. If @@ -81356,6 +81913,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// The change text document notification's parameters. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#didChangeTextDocumentParams -type DidChangeTextDocumentParams struct { - // The document that did change. The version number points - // to the version after all provided content changes have @@ -81375,6 +81934,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - // you receive them. - ContentChanges []TextDocumentContentChangeEvent `json:"contentChanges"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#didChangeWatchedFilesClientCapabilities -type DidChangeWatchedFilesClientCapabilities struct { - // Did change watched files notification supports dynamic registration. Please note - // that the current protocol doesn't support static configuration for file changes @@ -81388,18 +81949,24 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// The watched files change notification's parameters. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#didChangeWatchedFilesParams -type DidChangeWatchedFilesParams struct { - // The actual file events. - Changes []FileEvent `json:"changes"` -} - -// Describe options to be used when registered for text document change events. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#didChangeWatchedFilesRegistrationOptions -type DidChangeWatchedFilesRegistrationOptions struct { - // The watchers to register. - Watchers []FileSystemWatcher `json:"watchers"` -} - -// The parameters of a `workspace/didChangeWorkspaceFolders` notification. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#didChangeWorkspaceFoldersParams -type DidChangeWorkspaceFoldersParams struct { - // The actual workspace folder change event. - Event WorkspaceFoldersChangeEvent `json:"event"` @@ -81408,6 +81975,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// The params sent in a close notebook document notification. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#didCloseNotebookDocumentParams -type DidCloseNotebookDocumentParams struct { - // The notebook document that got closed. - NotebookDocument NotebookDocumentIdentifier `json:"notebookDocument"` @@ -81417,6 +81986,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// The parameters sent in a close text document notification +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#didCloseTextDocumentParams -type DidCloseTextDocumentParams struct { - // The document that was closed. - TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -81425,6 +81996,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// The params sent in an open notebook document notification. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#didOpenNotebookDocumentParams -type DidOpenNotebookDocumentParams struct { - // The notebook document that got opened. - NotebookDocument NotebookDocument `json:"notebookDocument"` @@ -81434,6 +82007,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// The parameters sent in an open text document notification +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#didOpenTextDocumentParams -type DidOpenTextDocumentParams struct { - // The document that was opened. - TextDocument TextDocumentItem `json:"textDocument"` @@ -81442,12 +82017,16 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// The params sent in a save notebook document notification. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#didSaveNotebookDocumentParams -type DidSaveNotebookDocumentParams struct { - // The notebook document that got saved. - NotebookDocument NotebookDocumentIdentifier `json:"notebookDocument"` -} - -// The parameters sent in a save text document notification +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#didSaveTextDocumentParams -type DidSaveTextDocumentParams struct { - // The document that was saved. - TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -81455,23 +82034,31 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - // when the save notification was requested. - Text *string `json:"text,omitempty"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentColorClientCapabilities -type DocumentColorClientCapabilities struct { - // Whether implementation supports dynamic registration. If this is set to `true` - // the client supports the new `DocumentColorRegistrationOptions` return value - // for the corresponding server capability as well. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentColorOptions -type DocumentColorOptions struct { - WorkDoneProgressOptions -} - -// Parameters for a {@link DocumentColorRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentColorParams -type DocumentColorParams struct { - // The text document. - TextDocument TextDocumentIdentifier `json:"textDocument"` - WorkDoneProgressParams - PartialResultParams -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentColorRegistrationOptions -type DocumentColorRegistrationOptions struct { - TextDocumentRegistrationOptions - DocumentColorOptions @@ -81481,6 +82068,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Parameters of the document diagnostic request. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentDiagnosticParams -type DocumentDiagnosticParams struct { - // The text document. - TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -81500,6 +82089,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// A partial result for a document diagnostic report. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentDiagnosticReportPartialResult -type DocumentDiagnosticReportPartialResult struct { - RelatedDocuments map[DocumentURI]interface{} `json:"relatedDocuments"` -} @@ -81508,19 +82099,27 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// a notebook cell document. -// -// @since 3.17.0 - proposed support for NotebookCellTextDocumentFilter. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentFilter -type DocumentFilter = Or_DocumentFilter // (alias) -// Client capabilities of a {@link DocumentFormattingRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentFormattingClientCapabilities -type DocumentFormattingClientCapabilities struct { - // Whether formatting supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` -} - -// Provider options for a {@link DocumentFormattingRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentFormattingOptions -type DocumentFormattingOptions struct { - WorkDoneProgressOptions -} - -// The parameters of a {@link DocumentFormattingRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentFormattingParams -type DocumentFormattingParams struct { - // The document to format. - TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -81530,6 +82129,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Registration options for a {@link DocumentFormattingRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentFormattingRegistrationOptions -type DocumentFormattingRegistrationOptions struct { - TextDocumentRegistrationOptions - DocumentFormattingOptions @@ -81538,6 +82139,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// A document highlight is a range inside a text document which deserves -// special attention. Usually a document highlight is visualized by changing -// the background color of its range. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentHighlight -type DocumentHighlight struct { - // The range this highlight applies to. - Range Range `json:"range"` @@ -81546,6 +82149,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Client Capabilities for a {@link DocumentHighlightRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentHighlightClientCapabilities -type DocumentHighlightClientCapabilities struct { - // Whether document highlight supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -81555,11 +82160,15 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -type DocumentHighlightKind uint32 - -// Provider options for a {@link DocumentHighlightRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentHighlightOptions -type DocumentHighlightOptions struct { - WorkDoneProgressOptions -} - -// Parameters for a {@link DocumentHighlightRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentHighlightParams -type DocumentHighlightParams struct { - TextDocumentPositionParams - WorkDoneProgressParams @@ -81567,6 +82176,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Registration options for a {@link DocumentHighlightRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentHighlightRegistrationOptions -type DocumentHighlightRegistrationOptions struct { - TextDocumentRegistrationOptions - DocumentHighlightOptions @@ -81574,6 +82185,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// A document link is a range in a text document that links to an internal or external resource, like another -// text document or a web site. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentLink -type DocumentLink struct { - // The range this link applies to. - Range Range `json:"range"` @@ -81593,6 +82206,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// The client capabilities of a {@link DocumentLinkRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentLinkClientCapabilities -type DocumentLinkClientCapabilities struct { - // Whether document link supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -81603,6 +82218,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Provider options for a {@link DocumentLinkRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentLinkOptions -type DocumentLinkOptions struct { - // Document links have a resolve provider as well. - ResolveProvider bool `json:"resolveProvider,omitempty"` @@ -81610,6 +82227,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// The parameters of a {@link DocumentLinkRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentLinkParams -type DocumentLinkParams struct { - // The document to provide document links for. - TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -81618,18 +82237,24 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Registration options for a {@link DocumentLinkRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentLinkRegistrationOptions -type DocumentLinkRegistrationOptions struct { - TextDocumentRegistrationOptions - DocumentLinkOptions -} - -// Client capabilities of a {@link DocumentOnTypeFormattingRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentOnTypeFormattingClientCapabilities -type DocumentOnTypeFormattingClientCapabilities struct { - // Whether on type formatting supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` -} - -// Provider options for a {@link DocumentOnTypeFormattingRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentOnTypeFormattingOptions -type DocumentOnTypeFormattingOptions struct { - // A character on which formatting should be triggered, like `{`. - FirstTriggerCharacter string `json:"firstTriggerCharacter"` @@ -81638,6 +82263,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// The parameters of a {@link DocumentOnTypeFormattingRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentOnTypeFormattingParams -type DocumentOnTypeFormattingParams struct { - // The document to format. - TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -81655,12 +82282,16 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Registration options for a {@link DocumentOnTypeFormattingRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentOnTypeFormattingRegistrationOptions -type DocumentOnTypeFormattingRegistrationOptions struct { - TextDocumentRegistrationOptions - DocumentOnTypeFormattingOptions -} - -// Client capabilities of a {@link DocumentRangeFormattingRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentRangeFormattingClientCapabilities -type DocumentRangeFormattingClientCapabilities struct { - // Whether range formatting supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -81672,6 +82303,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Provider options for a {@link DocumentRangeFormattingRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentRangeFormattingOptions -type DocumentRangeFormattingOptions struct { - // Whether the server supports formatting multiple ranges at once. - // @@ -81682,6 +82315,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// The parameters of a {@link DocumentRangeFormattingRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentRangeFormattingParams -type DocumentRangeFormattingParams struct { - // The document to format. - TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -81693,6 +82328,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Registration options for a {@link DocumentRangeFormattingRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentRangeFormattingRegistrationOptions -type DocumentRangeFormattingRegistrationOptions struct { - TextDocumentRegistrationOptions - DocumentRangeFormattingOptions @@ -81702,6 +82339,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentRangesFormattingParams -type DocumentRangesFormattingParams struct { - // The document to format. - TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -81717,11 +82356,15 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// @sample `let sel:DocumentSelector = [{ language: 'typescript' }, { language: 'json', pattern: '**∕tsconfig.json' }]`; -// -// The use of a string as a document filter is deprecated @since 3.16.0. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentSelector -type DocumentSelector = []DocumentFilter // (alias) -// Represents programming constructs like variables, classes, interfaces etc. -// that appear in a document. Document symbols can be hierarchical and they -// have two ranges: one that encloses its definition and one that points to -// its most interesting range, e.g. the range of an identifier. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentSymbol -type DocumentSymbol struct { - // The name of this symbol. Will be displayed in the user interface and therefore must not be - // an empty string or a string only consisting of white spaces. @@ -81750,6 +82393,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Client Capabilities for a {@link DocumentSymbolRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentSymbolClientCapabilities -type DocumentSymbolClientCapabilities struct { - // Whether document symbol supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -81772,6 +82417,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Provider options for a {@link DocumentSymbolRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentSymbolOptions -type DocumentSymbolOptions struct { - // A human-readable string that is shown when multiple outlines trees - // are shown for the same document. @@ -81782,6 +82429,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Parameters for a {@link DocumentSymbolRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentSymbolParams -type DocumentSymbolParams struct { - // The text document. - TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -81790,6 +82439,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Registration options for a {@link DocumentSymbolRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentSymbolRegistrationOptions -type DocumentSymbolRegistrationOptions struct { - TextDocumentRegistrationOptions - DocumentSymbolOptions @@ -81799,6 +82450,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#editRangeWithInsertReplace -type EditRangeWithInsertReplace struct { - Insert Range `json:"insert"` - Replace Range `json:"replace"` @@ -81808,12 +82461,16 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -type ErrorCodes int32 - -// The client capabilities of a {@link ExecuteCommandRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#executeCommandClientCapabilities -type ExecuteCommandClientCapabilities struct { - // Execute command supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` -} - -// The server capabilities of a {@link ExecuteCommandRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#executeCommandOptions -type ExecuteCommandOptions struct { - // The commands to be executed on the server - Commands []string `json:"commands"` @@ -81821,6 +82478,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// The parameters of a {@link ExecuteCommandRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#executeCommandParams -type ExecuteCommandParams struct { - // The identifier of the actual command handler. - Command string `json:"command"` @@ -81830,9 +82489,13 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Registration options for a {@link ExecuteCommandRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#executeCommandRegistrationOptions -type ExecuteCommandRegistrationOptions struct { - ExecuteCommandOptions -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#executionSummary -type ExecutionSummary struct { - // A strict monotonically increasing value - // indicating the execution order of a cell @@ -81850,6 +82513,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Represents information on a file/folder create. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#fileCreate -type FileCreate struct { - // A file:// URI for the location of the file/folder being created. - URI string `json:"uri"` @@ -81858,12 +82523,16 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Represents information on a file/folder delete. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#fileDelete -type FileDelete struct { - // A file:// URI for the location of the file/folder being deleted. - URI string `json:"uri"` -} - -// An event describing a file change. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#fileEvent -type FileEvent struct { - // The file's uri. - URI DocumentURI `json:"uri"` @@ -81877,6 +82546,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// like renaming a file in the UI. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#fileOperationClientCapabilities -type FileOperationClientCapabilities struct { - // Whether the client supports dynamic registration for file requests/notifications. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -81898,6 +82569,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// the server is interested in receiving. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#fileOperationFilter -type FileOperationFilter struct { - // A Uri scheme like `file` or `untitled`. - Scheme string `json:"scheme,omitempty"` @@ -81908,6 +82581,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Options for notifications/requests for user operations on files. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#fileOperationOptions -type FileOperationOptions struct { - // The server is interested in receiving didCreateFiles notifications. - DidCreate *FileOperationRegistrationOptions `json:"didCreate,omitempty"` @@ -81927,6 +82602,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// the server is interested in receiving. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#fileOperationPattern -type FileOperationPattern struct { - // The glob pattern to match. Glob patterns can have the following syntax: - // @@ -81954,6 +82631,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Matching options for the file operation pattern. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#fileOperationPatternOptions -type FileOperationPatternOptions struct { - // The pattern should be matched ignoring casing. - IgnoreCase bool `json:"ignoreCase,omitempty"` @@ -81962,6 +82641,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// The options to register for file operations. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#fileOperationRegistrationOptions -type FileOperationRegistrationOptions struct { - // The actual filters. - Filters []FileOperationFilter `json:"filters"` @@ -81970,12 +82651,16 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Represents information on a file/folder rename. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#fileRename -type FileRename struct { - // A file:// URI for the original location of the file/folder being renamed. - OldURI string `json:"oldUri"` - // A file:// URI for the new location of the file/folder being renamed. - NewURI string `json:"newUri"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#fileSystemWatcher -type FileSystemWatcher struct { - // The glob pattern to watch. See {@link GlobPattern glob pattern} for more detail. - // @@ -81989,6 +82674,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// Represents a folding range. To be valid, start and end line must be bigger than zero and smaller -// than the number of lines in the document. Clients are free to ignore invalid ranges. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#foldingRange -type FoldingRange struct { - // The zero-based start line of the range to fold. The folded area starts after the line's last character. - // To be valid, the end must be zero or larger and smaller than the number of lines in the document. @@ -82011,6 +82698,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - // @since 3.17.0 - CollapsedText string `json:"collapsedText,omitempty"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#foldingRangeClientCapabilities -type FoldingRangeClientCapabilities struct { - // Whether implementation supports dynamic registration for folding range - // providers. If this is set to `true` the client supports the new @@ -82037,17 +82726,23 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// A set of predefined range kinds. -type FoldingRangeKind string +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#foldingRangeOptions -type FoldingRangeOptions struct { - WorkDoneProgressOptions -} - -// Parameters for a {@link FoldingRangeRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#foldingRangeParams -type FoldingRangeParams struct { - // The text document. - TextDocument TextDocumentIdentifier `json:"textDocument"` - WorkDoneProgressParams - PartialResultParams -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#foldingRangeRegistrationOptions -type FoldingRangeRegistrationOptions struct { - TextDocumentRegistrationOptions - FoldingRangeOptions @@ -82058,6 +82753,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#foldingRangeWorkspaceClientCapabilities -type FoldingRangeWorkspaceClientCapabilities struct { - // Whether the client implementation supports a refresh request sent from the - // server to the client. @@ -82073,6 +82770,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Value-object describing what options formatting should use. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#formattingOptions -type FormattingOptions struct { - // Size of a tab in spaces. - TabSize uint32 `json:"tabSize"` @@ -82095,6 +82794,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// A diagnostic report with a full set of problems. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#fullDocumentDiagnosticReport -type FullDocumentDiagnosticReport struct { - // A full document diagnostic report. - Kind string `json:"kind"` @@ -82109,6 +82810,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// General client capabilities. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#generalClientCapabilities -type GeneralClientCapabilities struct { - // Client capability that signals how the client - // handles stale requests (e.g. a request @@ -82149,8 +82852,12 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// The glob pattern. Either a string pattern or a relative pattern. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#globPattern -type GlobPattern = Or_GlobPattern // (alias) -// The result of a hover request. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#hover -type Hover struct { - // The hover's content - Contents MarkupContent `json:"contents"` @@ -82158,6 +82865,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - // visualize the hover, e.g. by changing the background color. - Range Range `json:"range,omitempty"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#hoverClientCapabilities -type HoverClientCapabilities struct { - // Whether hover supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -82167,23 +82876,31 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Hover options. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#hoverOptions -type HoverOptions struct { - WorkDoneProgressOptions -} - -// Parameters for a {@link HoverRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#hoverParams -type HoverParams struct { - TextDocumentPositionParams - WorkDoneProgressParams -} - -// Registration options for a {@link HoverRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#hoverRegistrationOptions -type HoverRegistrationOptions struct { - TextDocumentRegistrationOptions - HoverOptions -} - -// @since 3.6.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#implementationClientCapabilities -type ImplementationClientCapabilities struct { - // Whether implementation supports dynamic registration. If this is set to `true` - // the client supports the new `ImplementationRegistrationOptions` return value @@ -82194,14 +82911,20 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - // @since 3.14.0 - LinkSupport bool `json:"linkSupport,omitempty"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#implementationOptions -type ImplementationOptions struct { - WorkDoneProgressOptions -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#implementationParams -type ImplementationParams struct { - TextDocumentPositionParams - WorkDoneProgressParams - PartialResultParams -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#implementationRegistrationOptions -type ImplementationRegistrationOptions struct { - TextDocumentRegistrationOptions - ImplementationOptions @@ -82210,6 +82933,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// The data type of the ResponseError if the -// initialize request fails. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#initializeError -type InitializeError struct { - // Indicates whether the client execute the following retry logic: - // (1) show the message provided by the ResponseError to the user @@ -82217,12 +82942,16 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - // (3) if user selected retry the initialize method is sent again. - Retry bool `json:"retry"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#initializeParams -type InitializeParams struct { - XInitializeParams - WorkspaceFoldersInitializeParams -} - -// The result returned from an initialize request. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#initializeResult -type InitializeResult struct { - // The capabilities the language server provides. - Capabilities ServerCapabilities `json:"capabilities"` @@ -82231,12 +82960,16 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - // @since 3.15.0 - ServerInfo *ServerInfo `json:"serverInfo,omitempty"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#initializedParams -type InitializedParams struct { -} - -// Inlay hint information. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlayHint -type InlayHint struct { - // The position of this hint. - // @@ -82279,6 +83012,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Inlay hint client capabilities. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlayHintClientCapabilities -type InlayHintClientCapabilities struct { - // Whether inlay hints support dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -82296,6 +83031,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// of inlay hints. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlayHintLabelPart -type InlayHintLabelPart struct { - // The value of this label part. - Value string `json:"value"` @@ -82325,6 +83062,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Inlay hint options used during static registration. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlayHintOptions -type InlayHintOptions struct { - // The server provides support to resolve additional - // information for an inlay hint item. @@ -82335,6 +83074,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// A parameter literal used in inlay hint requests. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlayHintParams -type InlayHintParams struct { - // The text document. - TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -82346,6 +83087,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Inlay hint options used during static or dynamic registration. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlayHintRegistrationOptions -type InlayHintRegistrationOptions struct { - InlayHintOptions - TextDocumentRegistrationOptions @@ -82355,6 +83098,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Client workspace capabilities specific to inlay hints. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlayHintWorkspaceClientCapabilities -type InlayHintWorkspaceClientCapabilities struct { - // Whether the client implementation supports a refresh request sent from - // the server to the client. @@ -82370,6 +83115,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineCompletionClientCapabilities -type InlineCompletionClientCapabilities struct { - // Whether implementation supports dynamic registration for inline completion providers. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -82379,6 +83126,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineCompletionContext -type InlineCompletionContext struct { - // Describes how the inline completion was triggered. - TriggerKind InlineCompletionTriggerKind `json:"triggerKind"` @@ -82390,6 +83139,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineCompletionItem -type InlineCompletionItem struct { - // The text to replace the range with. Must be set. - InsertText Or_InlineCompletionItem_insertText `json:"insertText"` @@ -82405,6 +83156,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineCompletionList -type InlineCompletionList struct { - // The inline completion items - Items []InlineCompletionItem `json:"items"` @@ -82414,6 +83167,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineCompletionOptions -type InlineCompletionOptions struct { - WorkDoneProgressOptions -} @@ -82422,6 +83177,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineCompletionParams -type InlineCompletionParams struct { - // Additional information about the context in which inline completions were - // requested. @@ -82434,6 +83191,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineCompletionRegistrationOptions -type InlineCompletionRegistrationOptions struct { - InlineCompletionOptions - TextDocumentRegistrationOptions @@ -82455,16 +83214,22 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// The InlineValue types combines all inline value types into one type. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineValue -type InlineValue = Or_InlineValue // (alias) -// Client capabilities specific to inline values. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineValueClientCapabilities -type InlineValueClientCapabilities struct { - // Whether implementation supports dynamic registration for inline value providers. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` -} - -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineValueContext -type InlineValueContext struct { - // The stack frame (as a DAP Id) where the execution has stopped. - FrameID int32 `json:"frameId"` @@ -82478,6 +83243,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// An optional expression can be used to override the extracted expression. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineValueEvaluatableExpression -type InlineValueEvaluatableExpression struct { - // The document range for which the inline value applies. - // The range is used to extract the evaluatable expression from the underlying document. @@ -82489,6 +83256,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Inline value options used during static registration. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineValueOptions -type InlineValueOptions struct { - WorkDoneProgressOptions -} @@ -82496,6 +83265,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// A parameter literal used in inline value requests. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineValueParams -type InlineValueParams struct { - // The text document. - TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -82510,6 +83281,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Inline value options used during static or dynamic registration. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineValueRegistrationOptions -type InlineValueRegistrationOptions struct { - InlineValueOptions - TextDocumentRegistrationOptions @@ -82519,6 +83292,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Provide inline value as text. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineValueText -type InlineValueText struct { - // The document range for which the inline value applies. - Range Range `json:"range"` @@ -82531,6 +83306,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// An optional variable name can be used to override the extracted name. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineValueVariableLookup -type InlineValueVariableLookup struct { - // The document range for which the inline value applies. - // The range is used to extract the variable name from the underlying document. @@ -82544,6 +83321,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Client workspace capabilities specific to inline values. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineValueWorkspaceClientCapabilities -type InlineValueWorkspaceClientCapabilities struct { - // Whether the client implementation supports a refresh request sent from the - // server to the client. @@ -82558,6 +83337,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// A special text edit to provide an insert and a replace operation. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#insertReplaceEdit -type InsertReplaceEdit struct { - // The string to be inserted. - NewText string `json:"newText"` @@ -82580,11 +83361,15 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// LSP arrays. -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#lSPArray -type LSPArray = []interface{} // (alias) -type LSPErrorCodes int32 - -// LSP object definition. -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#lSPObject -type LSPObject = map[string]LSPAny // (alias) -// Predefined Language kinds -// @since 3.18.0 @@ -82594,19 +83379,27 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Client capabilities for the linked editing range request. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#linkedEditingRangeClientCapabilities -type LinkedEditingRangeClientCapabilities struct { - // Whether implementation supports dynamic registration. If this is set to `true` - // the client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)` - // return value for the corresponding server capability as well. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#linkedEditingRangeOptions -type LinkedEditingRangeOptions struct { - WorkDoneProgressOptions -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#linkedEditingRangeParams -type LinkedEditingRangeParams struct { - TextDocumentPositionParams - WorkDoneProgressParams -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#linkedEditingRangeRegistrationOptions -type LinkedEditingRangeRegistrationOptions struct { - TextDocumentRegistrationOptions - LinkedEditingRangeOptions @@ -82616,6 +83409,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// The result of a linked editing range request. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#linkedEditingRanges -type LinkedEditingRanges struct { - // A list of ranges that can be edited together. The ranges must have - // identical length and contain identical text content. The ranges cannot overlap. @@ -82632,6 +83427,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// Represents a location inside a resource, such as a line -// inside a text file. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#location -type Location struct { - URI DocumentURI `json:"uri"` - Range Range `json:"range"` @@ -82639,6 +83436,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// Represents the connection of two locations. Provides additional metadata over normal {@link Location locations}, -// including an origin range. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#locationLink -type LocationLink struct { - // Span of the origin of this link. - // @@ -82660,17 +83459,23 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#locationUriOnly -type LocationUriOnly struct { - URI DocumentURI `json:"uri"` -} - -// The log message parameters. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#logMessageParams -type LogMessageParams struct { - // The message type. See {@link MessageType} - Type MessageType `json:"type"` - // The actual message. - Message string `json:"message"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#logTraceParams -type LogTraceParams struct { - Message string `json:"message"` - Verbose string `json:"verbose,omitempty"` @@ -82679,6 +83484,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Client capabilities specific to the used markdown parser. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#markdownClientCapabilities -type MarkdownClientCapabilities struct { - // The name of the parser. - Parser string `json:"parser"` @@ -82703,10 +83510,14 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// Note that markdown strings will be sanitized - that means html will be escaped. -// @deprecated use MarkupContent instead. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#markedString -type MarkedString = Or_MarkedString // (alias) -// @since 3.18.0 -// @proposed -// @deprecated use MarkupContent instead. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#markedStringWithLanguage -type MarkedStringWithLanguage struct { - Language string `json:"language"` - Value string `json:"value"` @@ -82736,6 +83547,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// *Please Note* that clients might sanitize the return markdown. A client could decide to -// remove HTML from the markdown to avoid script execution. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#markupContent -type MarkupContent struct { - // The type of the Markup - Kind MarkupKind `json:"kind"` @@ -82749,6 +83562,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Please note that `MarkupKinds` must not start with a `$`. This kinds -// are reserved for internal usage. -type MarkupKind string +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#messageActionItem -type MessageActionItem struct { - // A short title like 'Retry', 'Open Log' etc. - Title string `json:"title"` @@ -82760,6 +83575,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Moniker definition to match LSIF 0.5 moniker definition. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#moniker -type Moniker struct { - // The scheme of the moniker. For example tsc or .Net - Scheme string `json:"scheme"` @@ -82775,6 +83592,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Client capabilities specific to the moniker request. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#monikerClientCapabilities -type MonikerClientCapabilities struct { - // Whether moniker supports dynamic registration. If this is set to `true` - // the client supports the new `MonikerRegistrationOptions` return value @@ -82786,14 +83605,20 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// @since 3.16.0 -type MonikerKind string +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#monikerOptions -type MonikerOptions struct { - WorkDoneProgressOptions -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#monikerParams -type MonikerParams struct { - TextDocumentPositionParams - WorkDoneProgressParams - PartialResultParams -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#monikerRegistrationOptions -type MonikerRegistrationOptions struct { - TextDocumentRegistrationOptions - MonikerOptions @@ -82806,6 +83631,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// notebook cell or the cell's text document. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookCell -type NotebookCell struct { - // The cell's kind - Kind NotebookCellKind `json:"kind"` @@ -82825,6 +83652,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// array from state S to S'. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookCellArrayChange -type NotebookCellArrayChange struct { - // The start oftest of the cell that changed. - Start uint32 `json:"start"` @@ -82841,6 +83670,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookCellLanguage -type NotebookCellLanguage struct { - Language string `json:"language"` -} @@ -82849,6 +83680,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// document by different properties. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookCellTextDocumentFilter -type NotebookCellTextDocumentFilter struct { - // A filter that matches against the notebook - // containing the notebook cell. If a string @@ -82865,6 +83698,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// A notebook document. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocument -type NotebookDocument struct { - // The notebook document's uri. - URI URI `json:"uri"` @@ -82886,6 +83721,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentCellChangeStructure -type NotebookDocumentCellChangeStructure struct { - // The change to the cell array. - Array NotebookCellArrayChange `json:"array"` @@ -82899,6 +83736,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentCellChanges -type NotebookDocumentCellChanges struct { - // Changes to the cell structure to add or - // remove cells. @@ -82914,6 +83753,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentCellContentChanges -type NotebookDocumentCellContentChanges struct { - Document VersionedTextDocumentIdentifier `json:"document"` - Changes []TextDocumentContentChangeEvent `json:"changes"` @@ -82922,6 +83763,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// A change event for a notebook document. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentChangeEvent -type NotebookDocumentChangeEvent struct { - // The changed meta data if any. - // @@ -82934,6 +83777,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Capabilities specific to the notebook document support. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentClientCapabilities -type NotebookDocumentClientCapabilities struct { - // Capabilities specific to notebook document synchronization - // @@ -82946,11 +83791,15 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// against the notebook's URI (same as with documents) -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentFilter -type NotebookDocumentFilter = Or_NotebookDocumentFilter // (alias) -// A notebook document filter where `notebookType` is required field. -// -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentFilterNotebookType -type NotebookDocumentFilterNotebookType struct { - // The type of the enclosing notebook. - NotebookType string `json:"notebookType"` @@ -82964,6 +83813,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentFilterPattern -type NotebookDocumentFilterPattern struct { - // The type of the enclosing notebook. - NotebookType string `json:"notebookType,omitempty"` @@ -82977,6 +83828,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentFilterScheme -type NotebookDocumentFilterScheme struct { - // The type of the enclosing notebook. - NotebookType string `json:"notebookType,omitempty"` @@ -82988,6 +83841,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentFilterWithCells -type NotebookDocumentFilterWithCells struct { - // The notebook to be synced If a string - // value is provided it matches against the @@ -82999,6 +83854,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentFilterWithNotebook -type NotebookDocumentFilterWithNotebook struct { - // The notebook to be synced If a string - // value is provided it matches against the @@ -83011,6 +83868,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// A literal to identify a notebook document in the client. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentIdentifier -type NotebookDocumentIdentifier struct { - // The notebook document's uri. - URI URI `json:"uri"` @@ -83019,6 +83878,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Notebook specific client capabilities. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentSyncClientCapabilities -type NotebookDocumentSyncClientCapabilities struct { - // Whether implementation supports dynamic registration. If this is - // set to `true` the client supports the new @@ -83042,6 +83903,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// cell will be synced. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentSyncOptions -type NotebookDocumentSyncOptions struct { - // The notebooks to be synced - NotebookSelector []Or_NotebookDocumentSyncOptions_notebookSelector_Elem `json:"notebookSelector"` @@ -83053,12 +83916,16 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Registration options specific to a notebook. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentSyncRegistrationOptions -type NotebookDocumentSyncRegistrationOptions struct { - NotebookDocumentSyncOptions - StaticRegistrationOptions -} - -// A text document identifier to optionally denote a specific version of a text document. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#optionalVersionedTextDocumentIdentifier -type OptionalVersionedTextDocumentIdentifier struct { - // The version number of this document. If a versioned text document identifier - // is sent from the server to the client and the file is not open in the editor @@ -83404,9 +84271,13 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// The parameters of a configuration request. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#configurationParams -type ParamConfiguration struct { - Items []ConfigurationItem `json:"items"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#initializeParams -type ParamInitialize struct { - XInitializeParams - WorkspaceFoldersInitializeParams @@ -83414,6 +84285,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// Represents a parameter of a callable-signature. A parameter can -// have a label and a doc-comment. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#parameterInformation -type ParameterInformation struct { - // The label of this parameter information. - // @@ -83432,6 +84305,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - // in the UI but can be omitted. - Documentation string `json:"documentation,omitempty"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#partialResultParams -type PartialResultParams struct { - // An optional token that a server can use to report partial results (e.g. streaming) to - // the client. @@ -83448,6 +84323,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// - `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`) -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#pattern -type Pattern = string // (alias) -// Position in a text document expressed as zero-based line and character -// offset. Prior to 3.17 the offsets were always based on a UTF-16 string @@ -83476,6 +84353,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// that denotes `\r|\n` or `\n|` where `|` represents the character offset. -// -// @since 3.17.0 - support for negotiated position encoding. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#position -type Position struct { - // Line position in a document (zero-based). - // @@ -83499,9 +84378,13 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#prepareRenameDefaultBehavior -type PrepareRenameDefaultBehavior struct { - DefaultBehavior bool `json:"defaultBehavior"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#prepareRenameParams -type PrepareRenameParams struct { - TextDocumentPositionParams - WorkDoneProgressParams @@ -83509,16 +84392,22 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#prepareRenamePlaceholder -type PrepareRenamePlaceholder struct { - Range Range `json:"range"` - Placeholder string `json:"placeholder"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#prepareRenameResult -type PrepareRenameResult = PrepareRenamePlaceholder // (alias) -type PrepareSupportDefaultBehavior uint32 - -// A previous result id in a workspace pull request. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#previousResultId -type PreviousResultID struct { - // The URI for which the client knowns a - // result id. @@ -83530,6 +84419,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// A previous result id in a workspace pull request. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#previousResultId -type PreviousResultId struct { - // The URI for which the client knowns a - // result id. @@ -83537,14 +84428,20 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - // The value of the previous result id. - Value string `json:"value"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#progressParams -type ProgressParams struct { - // The progress token provided by the client or server. - Token ProgressToken `json:"token"` - // The progress data. - Value interface{} `json:"value"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#progressToken -type ProgressToken = interface{} // (alias) -// The publish diagnostic client capabilities. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#publishDiagnosticsClientCapabilities -type PublishDiagnosticsClientCapabilities struct { - // Whether the clients accepts diagnostics with related information. - RelatedInformation bool `json:"relatedInformation,omitempty"` @@ -83571,6 +84468,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// The publish diagnostic notification's parameters. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#publishDiagnosticsParams -type PublishDiagnosticsParams struct { - // The URI for which diagnostic information is reported. - URI DocumentURI `json:"uri"` @@ -83595,6 +84494,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// } -// -// ``` +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#range -type Range struct { - // The range's start position. - Start Position `json:"start"` @@ -83603,6 +84504,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Client Capabilities for a {@link ReferencesRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#referenceClientCapabilities -type ReferenceClientCapabilities struct { - // Whether references supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -83610,17 +84513,23 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// Value-object that contains additional information when -// requesting references. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#referenceContext -type ReferenceContext struct { - // Include the declaration of the current symbol. - IncludeDeclaration bool `json:"includeDeclaration"` -} - -// Reference options. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#referenceOptions -type ReferenceOptions struct { - WorkDoneProgressOptions -} - -// Parameters for a {@link ReferencesRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#referenceParams -type ReferenceParams struct { - Context ReferenceContext `json:"context"` - TextDocumentPositionParams @@ -83629,12 +84538,16 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Registration options for a {@link ReferencesRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#referenceRegistrationOptions -type ReferenceRegistrationOptions struct { - TextDocumentRegistrationOptions - ReferenceOptions -} - -// General parameters to register for a notification or to register a provider. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#registration -type Registration struct { - // The id used to register the request. The id can be used to deregister - // the request again. @@ -83644,13 +84557,19 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - // Options necessary for the registration. - RegisterOptions interface{} `json:"registerOptions,omitempty"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#registrationParams -type RegistrationParams struct { - Registrations []Registration `json:"registrations"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#regularExpressionEngineKind -type RegularExpressionEngineKind = string // (alias) -// Client capabilities specific to regular expressions. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#regularExpressionsClientCapabilities -type RegularExpressionsClientCapabilities struct { - // The engine's name. - Engine RegularExpressionEngineKind `json:"engine"` @@ -83661,6 +84580,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// A full diagnostic report with a set of related documents. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#relatedFullDocumentDiagnosticReport -type RelatedFullDocumentDiagnosticReport struct { - // Diagnostics of related documents. This information is useful - // in programming languages where code in a file A can generate @@ -83676,6 +84597,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// An unchanged diagnostic report with a set of related documents. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#relatedUnchangedDocumentDiagnosticReport -type RelatedUnchangedDocumentDiagnosticReport struct { - // Diagnostics of related documents. This information is useful - // in programming languages where code in a file A can generate @@ -83693,6 +84616,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// folder root, but it can be another absolute URI as well. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#relativePattern -type RelativePattern struct { - // A workspace folder or a base URI to which this pattern will be matched - // against relatively. @@ -83700,6 +84625,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - // The actual glob pattern; - Pattern Pattern `json:"pattern"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#renameClientCapabilities -type RenameClientCapabilities struct { - // Whether rename supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -83726,6 +84653,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Rename file operation +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#renameFile -type RenameFile struct { - // A rename - Kind string `json:"kind"` @@ -83739,6 +84668,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Rename file options +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#renameFileOptions -type RenameFileOptions struct { - // Overwrite target if existing. Overwrite wins over `ignoreIfExists` - Overwrite bool `json:"overwrite,omitempty"` @@ -83750,6 +84681,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// files. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#renameFilesParams -type RenameFilesParams struct { - // An array of all files/folders renamed in this operation. When a folder is renamed, only - // the folder will be included, and not its children. @@ -83757,6 +84690,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Provider options for a {@link RenameRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#renameOptions -type RenameOptions struct { - // Renames should be checked and tested before being executed. - // @@ -83766,6 +84701,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// The parameters of a {@link RenameRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#renameParams -type RenameParams struct { - // The document to rename. - TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -83779,12 +84716,16 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Registration options for a {@link RenameRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#renameRegistrationOptions -type RenameRegistrationOptions struct { - TextDocumentRegistrationOptions - RenameOptions -} - -// A generic resource operation. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#resourceOperation -type ResourceOperation struct { - // The resource operation kind. - Kind string `json:"kind"` @@ -83796,6 +84737,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -type ResourceOperationKind string - -// Save options. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#saveOptions -type SaveOptions struct { - // The client is supposed to include the content on save. - IncludeText bool `json:"includeText,omitempty"` @@ -83805,6 +84748,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#selectedCompletionInfo -type SelectedCompletionInfo struct { - // The range that will be replaced if this completion item is accepted. - Range Range `json:"range"` @@ -83814,23 +84759,31 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// A selection range represents a part of a selection hierarchy. A selection range -// may have a parent selection range that contains it. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#selectionRange -type SelectionRange struct { - // The {@link Range range} of this selection range. - Range Range `json:"range"` - // The parent selection range containing this range. Therefore `parent.range` must contain `this.range`. - Parent *SelectionRange `json:"parent,omitempty"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#selectionRangeClientCapabilities -type SelectionRangeClientCapabilities struct { - // Whether implementation supports dynamic registration for selection range providers. If this is set to `true` - // the client supports the new `SelectionRangeRegistrationOptions` return value for the corresponding server - // capability as well. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#selectionRangeOptions -type SelectionRangeOptions struct { - WorkDoneProgressOptions -} - -// A parameter literal used in selection range requests. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#selectionRangeParams -type SelectionRangeParams struct { - // The text document. - TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -83839,6 +84792,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - WorkDoneProgressParams - PartialResultParams -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#selectionRangeRegistrationOptions -type SelectionRangeRegistrationOptions struct { - SelectionRangeOptions - TextDocumentRegistrationOptions @@ -83860,6 +84815,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -type SemanticTokenTypes string - -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#semanticTokens -type SemanticTokens struct { - // An optional result id. If provided and clients support delta updating - // the client will include the result id in the next semantic token request. @@ -83871,6 +84828,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#semanticTokensClientCapabilities -type SemanticTokensClientCapabilities struct { - // Whether implementation supports dynamic registration. If this is set to `true` - // the client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)` @@ -83916,6 +84875,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#semanticTokensDelta -type SemanticTokensDelta struct { - ResultID string `json:"resultId,omitempty"` - // The semantic token edits to transform a previous result into a new result. @@ -83923,6 +84884,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#semanticTokensDeltaParams -type SemanticTokensDeltaParams struct { - // The text document. - TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -83934,11 +84897,15 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#semanticTokensDeltaPartialResult -type SemanticTokensDeltaPartialResult struct { - Edits []SemanticTokensEdit `json:"edits"` -} - -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#semanticTokensEdit -type SemanticTokensEdit struct { - // The start offset of the edit. - Start uint32 `json:"start"` @@ -83952,12 +84919,16 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#semanticTokensFullDelta -type SemanticTokensFullDelta struct { - // The server supports deltas for full documents. - Delta bool `json:"delta,omitempty"` -} - -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#semanticTokensLegend -type SemanticTokensLegend struct { - // The token types a server uses. - TokenTypes []string `json:"tokenTypes"` @@ -83966,6 +84937,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#semanticTokensOptions -type SemanticTokensOptions struct { - // The legend used by the server - Legend SemanticTokensLegend `json:"legend"` @@ -83978,6 +84951,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#semanticTokensParams -type SemanticTokensParams struct { - // The text document. - TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -83986,11 +84961,15 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#semanticTokensPartialResult -type SemanticTokensPartialResult struct { - Data []uint32 `json:"data"` -} - -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#semanticTokensRangeParams -type SemanticTokensRangeParams struct { - // The text document. - TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -84001,6 +84980,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#semanticTokensRegistrationOptions -type SemanticTokensRegistrationOptions struct { - TextDocumentRegistrationOptions - SemanticTokensOptions @@ -84008,6 +84989,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#semanticTokensWorkspaceClientCapabilities -type SemanticTokensWorkspaceClientCapabilities struct { - // Whether the client implementation supports a refresh request sent from - // the server to the client. @@ -84021,6 +85004,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// Defines the capabilities provided by a language -// server. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#serverCapabilities -type ServerCapabilities struct { - // The position encoding the server picked from the encodings offered - // by the client via the client capability `general.positionEncodings`. @@ -84133,6 +85118,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#serverCompletionItemOptions -type ServerCompletionItemOptions struct { - // The server has support for completion item label - // details (see also `CompletionItemLabelDetails`) when @@ -84147,12 +85134,16 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// @since 3.15.0 -// @since 3.18.0 ServerInfo type name added. -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#serverInfo -type ServerInfo struct { - // The name of the server as defined by the server. - Name string `json:"name"` - // The server's version as defined by the server. - Version string `json:"version,omitempty"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#setTraceParams -type SetTraceParams struct { - Value TraceValue `json:"value"` -} @@ -84160,6 +85151,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Client capabilities for the showDocument request. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#showDocumentClientCapabilities -type ShowDocumentClientCapabilities struct { - // The client has support for the showDocument - // request. @@ -84169,6 +85162,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Params to show a resource in the UI. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#showDocumentParams -type ShowDocumentParams struct { - // The uri to show. - URI URI `json:"uri"` @@ -84191,12 +85186,16 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// The result of a showDocument request. -// -// @since 3.16.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#showDocumentResult -type ShowDocumentResult struct { - // A boolean indicating if the show was successful. - Success bool `json:"success"` -} - -// The parameters of a notification message. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#showMessageParams -type ShowMessageParams struct { - // The message type. See {@link MessageType} - Type MessageType `json:"type"` @@ -84205,10 +85204,14 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Show message request client capabilities +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#showMessageRequestClientCapabilities -type ShowMessageRequestClientCapabilities struct { - // Capabilities specific to the `MessageActionItem` type. - MessageActionItem *ClientShowMessageActionItemOptions `json:"messageActionItem,omitempty"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#showMessageRequestParams -type ShowMessageRequestParams struct { - // The message type. See {@link MessageType} - Type MessageType `json:"type"` @@ -84221,6 +85224,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Signature help represents the signature of something -// callable. There can be multiple signature but only one -// active and only one active parameter. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#signatureHelp -type SignatureHelp struct { - // One or more signatures. - Signatures []SignatureInformation `json:"signatures"` @@ -84254,6 +85259,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Client Capabilities for a {@link SignatureHelpRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#signatureHelpClientCapabilities -type SignatureHelpClientCapabilities struct { - // Whether signature help supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -84272,6 +85279,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Additional information about the context in which a signature help request was triggered. -// -// @since 3.15.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#signatureHelpContext -type SignatureHelpContext struct { - // Action that caused signature help to be triggered. - TriggerKind SignatureHelpTriggerKind `json:"triggerKind"` @@ -84292,6 +85301,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Server Capabilities for a {@link SignatureHelpRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#signatureHelpOptions -type SignatureHelpOptions struct { - // List of characters that trigger signature help automatically. - TriggerCharacters []string `json:"triggerCharacters,omitempty"` @@ -84306,6 +85317,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Parameters for a {@link SignatureHelpRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#signatureHelpParams -type SignatureHelpParams struct { - // The signature help context. This is only available if the client specifies - // to send this using the client capability `textDocument.signatureHelp.contextSupport === true` @@ -84317,6 +85330,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Registration options for a {@link SignatureHelpRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#signatureHelpRegistrationOptions -type SignatureHelpRegistrationOptions struct { - TextDocumentRegistrationOptions - SignatureHelpOptions @@ -84330,6 +85345,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Represents the signature of something callable. A signature -// can have a label, like a function-name, a doc-comment, and -// a set of parameters. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#signatureInformation -type SignatureInformation struct { - // The label of this signature. Will be shown in - // the UI. @@ -84355,6 +85372,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#staleRequestSupportOptions -type StaleRequestSupportOptions struct { - // The client will actively cancel the request. - Cancel bool `json:"cancel"` @@ -84366,6 +85385,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// Static registration options to be returned in the initialize -// request. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#staticRegistrationOptions -type StaticRegistrationOptions struct { - // The id used to register the request. The id can be used to deregister - // the request again. See also Registration#id. @@ -84382,6 +85403,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#stringValue -type StringValue struct { - // The kind of string value. - Kind string `json:"kind"` @@ -84391,6 +85414,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// Represents information about programming constructs like variables, classes, -// interfaces etc. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#symbolInformation -type SymbolInformation struct { - // extends BaseSymbolInformation - // Indicates if this symbol is deprecated. @@ -84431,6 +85456,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -type SymbolTag uint32 - -// Describe options to be used when registered for text document change events. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentChangeRegistrationOptions -type TextDocumentChangeRegistrationOptions struct { - // How documents are synced to the server. - SyncKind TextDocumentSyncKind `json:"syncKind"` @@ -84438,6 +85465,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Text document specific client capabilities. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentClientCapabilities -type TextDocumentClientCapabilities struct { - // Defines which synchronization capabilities the client supports. - Synchronization *TextDocumentSyncClientCapabilities `json:"synchronization,omitempty"` @@ -84537,9 +85566,13 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// An event describing a change to a text document. If only a text is provided -// it is considered to be the full content of the document. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentContentChangeEvent -type TextDocumentContentChangeEvent = TextDocumentContentChangePartial // (alias) -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentContentChangePartial -type TextDocumentContentChangePartial struct { - // The range of the document that changed. - Range *Range `json:"range,omitempty"` @@ -84553,6 +85586,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentContentChangeWholeDocument -type TextDocumentContentChangeWholeDocument struct { - // The new text of the whole document. - Text string `json:"text"` @@ -84562,6 +85597,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// on a document version Si and after they are applied move the document to version Si+1. -// So the creator of a TextDocumentEdit doesn't need to sort the array of edits or do any -// kind of ordering. However the edits must be non overlapping. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentEdit -type TextDocumentEdit struct { - // The text document to change. - TextDocument OptionalVersionedTextDocumentIdentifier `json:"textDocument"` @@ -84589,11 +85626,15 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// @sample A language filter that applies to all package.json paths: `{ language: 'json', pattern: '**package.json' }` -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentFilter -type TextDocumentFilter = Or_TextDocumentFilter // (alias) -// A document filter where `language` is required field. -// -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentFilterLanguage -type TextDocumentFilterLanguage struct { - // A language id, like `typescript`. - Language string `json:"language"` @@ -84607,6 +85648,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentFilterPattern -type TextDocumentFilterPattern struct { - // A language id, like `typescript`. - Language string `json:"language,omitempty"` @@ -84620,6 +85663,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentFilterScheme -type TextDocumentFilterScheme struct { - // A language id, like `typescript`. - Language string `json:"language,omitempty"` @@ -84630,6 +85675,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// A literal to identify a text document in the client. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentIdentifier -type TextDocumentIdentifier struct { - // The text document's uri. - URI DocumentURI `json:"uri"` @@ -84637,6 +85684,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// An item to transfer a text document from the client to the -// server. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentItem -type TextDocumentItem struct { - // The text document's uri. - URI DocumentURI `json:"uri"` @@ -84651,6 +85700,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - -// A parameter literal used in requests to pass a text document and a position inside that -// document. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentPositionParams -type TextDocumentPositionParams struct { - // The text document. - TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -84659,6 +85710,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// General text document registration options. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentRegistrationOptions -type TextDocumentRegistrationOptions struct { - // A document selector to identify the scope of the registration. If set to null - // the document selector provided on the client side will be used. @@ -84669,10 +85722,14 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -type TextDocumentSaveReason uint32 - -// Save registration options. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentSaveRegistrationOptions -type TextDocumentSaveRegistrationOptions struct { - TextDocumentRegistrationOptions - SaveOptions -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentSyncClientCapabilities -type TextDocumentSyncClientCapabilities struct { - // Whether text document synchronization supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -84689,6 +85746,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Defines how the host (editor) should sync -// document changes to the language server. -type TextDocumentSyncKind uint32 +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentSyncOptions -type TextDocumentSyncOptions struct { - // Open and close notifications are sent to the server. If omitted open close notification should not - // be sent. @@ -84708,6 +85767,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// A text edit applicable to a text document. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textEdit -type TextEdit struct { - // The range of the text document to be manipulated. To insert - // text into a document create a range where start === end. @@ -84720,6 +85781,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -type TraceValue string - -// Since 3.6.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#typeDefinitionClientCapabilities -type TypeDefinitionClientCapabilities struct { - // Whether implementation supports dynamic registration. If this is set to `true` - // the client supports the new `TypeDefinitionRegistrationOptions` return value @@ -84730,14 +85793,20 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - // Since 3.14.0 - LinkSupport bool `json:"linkSupport,omitempty"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#typeDefinitionOptions -type TypeDefinitionOptions struct { - WorkDoneProgressOptions -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#typeDefinitionParams -type TypeDefinitionParams struct { - TextDocumentPositionParams - WorkDoneProgressParams - PartialResultParams -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#typeDefinitionRegistrationOptions -type TypeDefinitionRegistrationOptions struct { - TextDocumentRegistrationOptions - TypeDefinitionOptions @@ -84745,6 +85814,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#typeHierarchyClientCapabilities -type TypeHierarchyClientCapabilities struct { - // Whether implementation supports dynamic registration. If this is set to `true` - // the client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)` @@ -84753,6 +85824,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#typeHierarchyItem -type TypeHierarchyItem struct { - // The name of this item. - Name string `json:"name"` @@ -84781,6 +85854,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Type hierarchy options used during static registration. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#typeHierarchyOptions -type TypeHierarchyOptions struct { - WorkDoneProgressOptions -} @@ -84788,6 +85863,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// The parameter of a `textDocument/prepareTypeHierarchy` request. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#typeHierarchyPrepareParams -type TypeHierarchyPrepareParams struct { - TextDocumentPositionParams - WorkDoneProgressParams @@ -84796,6 +85873,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Type hierarchy options used during static or dynamic registration. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#typeHierarchyRegistrationOptions -type TypeHierarchyRegistrationOptions struct { - TextDocumentRegistrationOptions - TypeHierarchyOptions @@ -84805,6 +85884,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// The parameter of a `typeHierarchy/subtypes` request. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#typeHierarchySubtypesParams -type TypeHierarchySubtypesParams struct { - Item TypeHierarchyItem `json:"item"` - WorkDoneProgressParams @@ -84814,6 +85895,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// The parameter of a `typeHierarchy/supertypes` request. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#typeHierarchySupertypesParams -type TypeHierarchySupertypesParams struct { - Item TypeHierarchyItem `json:"item"` - WorkDoneProgressParams @@ -84830,6 +85913,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// report is still accurate. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#unchangedDocumentDiagnosticReport -type UnchangedDocumentDiagnosticReport struct { - // A document diagnostic report indicating - // no changes to the last result. A server can @@ -84847,6 +85932,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -type UniquenessLevel string - -// General parameters to unregister a request or notification. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#unregistration -type Unregistration struct { - // The id used to unregister the request or notification. Usually an id - // provided during the register request. @@ -84854,6 +85941,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - // The method to unregister for. - Method string `json:"method"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#unregistrationParams -type UnregistrationParams struct { - Unregisterations []Unregistration `json:"unregisterations"` -} @@ -84861,6 +85950,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// A versioned notebook document identifier. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#versionedNotebookDocumentIdentifier -type VersionedNotebookDocumentIdentifier struct { - // The version number of this notebook document. - Version int32 `json:"version"` @@ -84869,18 +85960,23 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// A text document identifier to denote a specific version of a text document. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#versionedTextDocumentIdentifier -type VersionedTextDocumentIdentifier struct { - // The version number of this document. - Version int32 `json:"version"` - TextDocumentIdentifier -} -type WatchKind = uint32 // The parameters sent in a will save text document notification. +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#willSaveTextDocumentParams -type WillSaveTextDocumentParams struct { - // The document that will be saved. - TextDocument TextDocumentIdentifier `json:"textDocument"` - // The 'TextDocumentSaveReason'. - Reason TextDocumentSaveReason `json:"reason"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#windowClientCapabilities -type WindowClientCapabilities struct { - // It indicates whether the client supports server initiated - // progress using the `window/workDoneProgress/create` request. @@ -84901,6 +85997,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - // @since 3.16.0 - ShowDocument *ShowDocumentClientCapabilities `json:"showDocument,omitempty"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workDoneProgressBegin -type WorkDoneProgressBegin struct { - Kind string `json:"kind"` - // Mandatory title of the progress operation. Used to briefly inform about @@ -84926,20 +86024,28 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - // that are not following this rule. The value range is [0, 100]. - Percentage uint32 `json:"percentage,omitempty"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workDoneProgressCancelParams -type WorkDoneProgressCancelParams struct { - // The token to be used to report progress. - Token ProgressToken `json:"token"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workDoneProgressCreateParams -type WorkDoneProgressCreateParams struct { - // The token to be used to report progress. - Token ProgressToken `json:"token"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workDoneProgressEnd -type WorkDoneProgressEnd struct { - Kind string `json:"kind"` - // Optional, a final message indicating to for example indicate the outcome - // of the operation. - Message string `json:"message,omitempty"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workDoneProgressOptions -type WorkDoneProgressOptions struct { - WorkDoneProgress bool `json:"workDoneProgress,omitempty"` -} @@ -84949,10 +86055,14 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - WorkDoneProgressOptions - TextDocumentRegistrationOptions -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workDoneProgressParams -type WorkDoneProgressParams struct { - // An optional token that a server can use to report work done progress. - WorkDoneToken ProgressToken `json:"workDoneToken,omitempty"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workDoneProgressReport -type WorkDoneProgressReport struct { - Kind string `json:"kind"` - // Controls enablement state of a cancel button. @@ -84976,6 +86086,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Workspace specific client capabilities. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceClientCapabilities -type WorkspaceClientCapabilities struct { - // The client supports applying batch edits - // to the workspace by supporting the request @@ -85038,6 +86150,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// Parameters of the workspace diagnostic request. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceDiagnosticParams -type WorkspaceDiagnosticParams struct { - // The additional identifier provided during registration. - Identifier string `json:"identifier,omitempty"` @@ -85051,6 +86165,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// A workspace diagnostic report. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceDiagnosticReport -type WorkspaceDiagnosticReport struct { - Items []WorkspaceDocumentDiagnosticReport `json:"items"` -} @@ -85058,6 +86174,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// A partial result for a workspace diagnostic report. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceDiagnosticReportPartialResult -type WorkspaceDiagnosticReportPartialResult struct { - Items []WorkspaceDocumentDiagnosticReport `json:"items"` -} @@ -85065,6 +86183,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// A workspace diagnostic document report. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceDocumentDiagnosticReport -type WorkspaceDocumentDiagnosticReport = Or_WorkspaceDocumentDiagnosticReport // (alias) -// A workspace edit represents changes to many resources managed in the workspace. The edit -// should either provide `changes` or `documentChanges`. If documentChanges are present @@ -85078,6 +86198,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// An invalid sequence (e.g. (1) delete file a.txt and (2) insert text into file a.txt) will -// cause failure of the operation. How the client recovers from the failure is described by -// the client capability: `workspace.workspaceEdit.failureHandling` +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceEdit -type WorkspaceEdit struct { - // Holds changes to existing resources. - Changes map[DocumentURI][]TextEdit `json:"changes,omitempty"` @@ -85100,6 +86222,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - // @since 3.16.0 - ChangeAnnotations map[ChangeAnnotationIdentifier]ChangeAnnotation `json:"changeAnnotations,omitempty"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceEditClientCapabilities -type WorkspaceEditClientCapabilities struct { - // The client supports versioned document changes in `WorkspaceEdit`s - DocumentChanges bool `json:"documentChanges,omitempty"` @@ -85129,6 +86253,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// A workspace folder inside a client. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceFolder -type WorkspaceFolder struct { - // The associated URI for this workspace folder. - URI URI `json:"uri"` @@ -85136,6 +86262,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - // workspace folder in the user interface. - Name string `json:"name"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceFoldersServerCapabilities -type WorkspaceFolders5Gn struct { - // The server has support for workspace folders - Supported bool `json:"supported,omitempty"` @@ -85150,12 +86278,16 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// The workspace folder change event. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceFoldersChangeEvent -type WorkspaceFoldersChangeEvent struct { - // The array of added workspace folders - Added []WorkspaceFolder `json:"added"` - // The array of the removed workspace folders - Removed []WorkspaceFolder `json:"removed"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceFoldersInitializeParams -type WorkspaceFoldersInitializeParams struct { - // The workspace folders configured in the client when the server starts. - // @@ -85166,6 +86298,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr - // @since 3.6.0 - WorkspaceFolders []WorkspaceFolder `json:"workspaceFolders,omitempty"` -} +- +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceFoldersServerCapabilities -type WorkspaceFoldersServerCapabilities struct { - // The server has support for workspace folders - Supported bool `json:"supported,omitempty"` @@ -85182,6 +86316,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// A full document diagnostic report for a workspace diagnostic result. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceFullDocumentDiagnosticReport -type WorkspaceFullDocumentDiagnosticReport struct { - // The URI for which diagnostic information is reported. - URI DocumentURI `json:"uri"` @@ -85195,6 +86331,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// -// @since 3.18.0 -// @proposed +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceOptions -type WorkspaceOptions struct { - // The server supports workspace folder. - // @@ -85211,6 +86349,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// See also SymbolInformation. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceSymbol -type WorkspaceSymbol struct { - // The location of the symbol. Whether a server is allowed to - // return a location without a range depends on the client @@ -85225,6 +86365,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Client capabilities for a {@link WorkspaceSymbolRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceSymbolClientCapabilities -type WorkspaceSymbolClientCapabilities struct { - // Symbol request supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -85244,6 +86386,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Server capabilities for a {@link WorkspaceSymbolRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceSymbolOptions -type WorkspaceSymbolOptions struct { - // The server provides support to resolve additional - // information for a workspace symbol. @@ -85254,6 +86398,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// The parameters of a {@link WorkspaceSymbolRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceSymbolParams -type WorkspaceSymbolParams struct { - // A query string to filter symbols by. Clients may send an empty - // string here to request all symbols. @@ -85263,6 +86409,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// Registration options for a {@link WorkspaceSymbolRequest}. +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceSymbolRegistrationOptions -type WorkspaceSymbolRegistrationOptions struct { - WorkspaceSymbolOptions -} @@ -85270,6 +86418,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -// An unchanged document diagnostic report for a workspace diagnostic result. -// -// @since 3.17.0 +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceUnchangedDocumentDiagnosticReport -type WorkspaceUnchangedDocumentDiagnosticReport struct { - // The URI for which diagnostic information is reported. - URI DocumentURI `json:"uri"` @@ -85280,6 +86430,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// The initialize parameters +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#_InitializeParams -type XInitializeParams struct { - // The process Id of the parent process that started - // the server. @@ -85321,6 +86473,8 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr -} - -// The initialize parameters +-// +-// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#_InitializeParams -type _InitializeParams struct { - // The process Id of the parent process that started - // the server. @@ -85907,7 +87061,7 @@ diff -urN a/gopls/internal/protocol/tsprotocol.go b/gopls/internal/protocol/tspr diff -urN a/gopls/internal/protocol/tsserver.go b/gopls/internal/protocol/tsserver.go --- a/gopls/internal/protocol/tsserver.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/protocol/tsserver.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,1262 +0,0 @@ +@@ -1,1334 +0,0 @@ -// Copyright 2023 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -85927,80 +87081,152 @@ diff -urN a/gopls/internal/protocol/tsserver.go b/gopls/internal/protocol/tsserv -) - -type Server interface { -- Progress(context.Context, *ProgressParams) error // $/progress -- SetTrace(context.Context, *SetTraceParams) error // $/setTrace -- IncomingCalls(context.Context, *CallHierarchyIncomingCallsParams) ([]CallHierarchyIncomingCall, error) // callHierarchy/incomingCalls -- OutgoingCalls(context.Context, *CallHierarchyOutgoingCallsParams) ([]CallHierarchyOutgoingCall, error) // callHierarchy/outgoingCalls -- ResolveCodeAction(context.Context, *CodeAction) (*CodeAction, error) // codeAction/resolve -- ResolveCodeLens(context.Context, *CodeLens) (*CodeLens, error) // codeLens/resolve -- ResolveCompletionItem(context.Context, *CompletionItem) (*CompletionItem, error) // completionItem/resolve -- ResolveDocumentLink(context.Context, *DocumentLink) (*DocumentLink, error) // documentLink/resolve -- Exit(context.Context) error // exit -- Initialize(context.Context, *ParamInitialize) (*InitializeResult, error) // initialize -- Initialized(context.Context, *InitializedParams) error // initialized -- Resolve(context.Context, *InlayHint) (*InlayHint, error) // inlayHint/resolve -- DidChangeNotebookDocument(context.Context, *DidChangeNotebookDocumentParams) error // notebookDocument/didChange -- DidCloseNotebookDocument(context.Context, *DidCloseNotebookDocumentParams) error // notebookDocument/didClose -- DidOpenNotebookDocument(context.Context, *DidOpenNotebookDocumentParams) error // notebookDocument/didOpen -- DidSaveNotebookDocument(context.Context, *DidSaveNotebookDocumentParams) error // notebookDocument/didSave -- Shutdown(context.Context) error // shutdown -- CodeAction(context.Context, *CodeActionParams) ([]CodeAction, error) // textDocument/codeAction -- CodeLens(context.Context, *CodeLensParams) ([]CodeLens, error) // textDocument/codeLens -- ColorPresentation(context.Context, *ColorPresentationParams) ([]ColorPresentation, error) // textDocument/colorPresentation -- Completion(context.Context, *CompletionParams) (*CompletionList, error) // textDocument/completion -- Declaration(context.Context, *DeclarationParams) (*Or_textDocument_declaration, error) // textDocument/declaration -- Definition(context.Context, *DefinitionParams) ([]Location, error) // textDocument/definition -- Diagnostic(context.Context, *string) (*string, error) // textDocument/diagnostic -- DidChange(context.Context, *DidChangeTextDocumentParams) error // textDocument/didChange -- DidClose(context.Context, *DidCloseTextDocumentParams) error // textDocument/didClose -- DidOpen(context.Context, *DidOpenTextDocumentParams) error // textDocument/didOpen -- DidSave(context.Context, *DidSaveTextDocumentParams) error // textDocument/didSave -- DocumentColor(context.Context, *DocumentColorParams) ([]ColorInformation, error) // textDocument/documentColor -- DocumentHighlight(context.Context, *DocumentHighlightParams) ([]DocumentHighlight, error) // textDocument/documentHighlight -- DocumentLink(context.Context, *DocumentLinkParams) ([]DocumentLink, error) // textDocument/documentLink -- DocumentSymbol(context.Context, *DocumentSymbolParams) ([]interface{}, error) // textDocument/documentSymbol -- FoldingRange(context.Context, *FoldingRangeParams) ([]FoldingRange, error) // textDocument/foldingRange -- Formatting(context.Context, *DocumentFormattingParams) ([]TextEdit, error) // textDocument/formatting -- Hover(context.Context, *HoverParams) (*Hover, error) // textDocument/hover -- Implementation(context.Context, *ImplementationParams) ([]Location, error) // textDocument/implementation -- InlayHint(context.Context, *InlayHintParams) ([]InlayHint, error) // textDocument/inlayHint -- InlineCompletion(context.Context, *InlineCompletionParams) (*Or_Result_textDocument_inlineCompletion, error) // textDocument/inlineCompletion -- InlineValue(context.Context, *InlineValueParams) ([]InlineValue, error) // textDocument/inlineValue -- LinkedEditingRange(context.Context, *LinkedEditingRangeParams) (*LinkedEditingRanges, error) // textDocument/linkedEditingRange -- Moniker(context.Context, *MonikerParams) ([]Moniker, error) // textDocument/moniker -- OnTypeFormatting(context.Context, *DocumentOnTypeFormattingParams) ([]TextEdit, error) // textDocument/onTypeFormatting -- PrepareCallHierarchy(context.Context, *CallHierarchyPrepareParams) ([]CallHierarchyItem, error) // textDocument/prepareCallHierarchy -- PrepareRename(context.Context, *PrepareRenameParams) (*PrepareRenameResult, error) // textDocument/prepareRename -- PrepareTypeHierarchy(context.Context, *TypeHierarchyPrepareParams) ([]TypeHierarchyItem, error) // textDocument/prepareTypeHierarchy -- RangeFormatting(context.Context, *DocumentRangeFormattingParams) ([]TextEdit, error) // textDocument/rangeFormatting -- RangesFormatting(context.Context, *DocumentRangesFormattingParams) ([]TextEdit, error) // textDocument/rangesFormatting -- References(context.Context, *ReferenceParams) ([]Location, error) // textDocument/references -- Rename(context.Context, *RenameParams) (*WorkspaceEdit, error) // textDocument/rename -- SelectionRange(context.Context, *SelectionRangeParams) ([]SelectionRange, error) // textDocument/selectionRange -- SemanticTokensFull(context.Context, *SemanticTokensParams) (*SemanticTokens, error) // textDocument/semanticTokens/full -- SemanticTokensFullDelta(context.Context, *SemanticTokensDeltaParams) (interface{}, error) // textDocument/semanticTokens/full/delta -- SemanticTokensRange(context.Context, *SemanticTokensRangeParams) (*SemanticTokens, error) // textDocument/semanticTokens/range -- SignatureHelp(context.Context, *SignatureHelpParams) (*SignatureHelp, error) // textDocument/signatureHelp -- TypeDefinition(context.Context, *TypeDefinitionParams) ([]Location, error) // textDocument/typeDefinition -- WillSave(context.Context, *WillSaveTextDocumentParams) error // textDocument/willSave -- WillSaveWaitUntil(context.Context, *WillSaveTextDocumentParams) ([]TextEdit, error) // textDocument/willSaveWaitUntil -- Subtypes(context.Context, *TypeHierarchySubtypesParams) ([]TypeHierarchyItem, error) // typeHierarchy/subtypes -- Supertypes(context.Context, *TypeHierarchySupertypesParams) ([]TypeHierarchyItem, error) // typeHierarchy/supertypes -- WorkDoneProgressCancel(context.Context, *WorkDoneProgressCancelParams) error // window/workDoneProgress/cancel -- DiagnosticWorkspace(context.Context, *WorkspaceDiagnosticParams) (*WorkspaceDiagnosticReport, error) // workspace/diagnostic -- DidChangeConfiguration(context.Context, *DidChangeConfigurationParams) error // workspace/didChangeConfiguration -- DidChangeWatchedFiles(context.Context, *DidChangeWatchedFilesParams) error // workspace/didChangeWatchedFiles -- DidChangeWorkspaceFolders(context.Context, *DidChangeWorkspaceFoldersParams) error // workspace/didChangeWorkspaceFolders -- DidCreateFiles(context.Context, *CreateFilesParams) error // workspace/didCreateFiles -- DidDeleteFiles(context.Context, *DeleteFilesParams) error // workspace/didDeleteFiles -- DidRenameFiles(context.Context, *RenameFilesParams) error // workspace/didRenameFiles -- ExecuteCommand(context.Context, *ExecuteCommandParams) (interface{}, error) // workspace/executeCommand -- Symbol(context.Context, *WorkspaceSymbolParams) ([]SymbolInformation, error) // workspace/symbol -- WillCreateFiles(context.Context, *CreateFilesParams) (*WorkspaceEdit, error) // workspace/willCreateFiles -- WillDeleteFiles(context.Context, *DeleteFilesParams) (*WorkspaceEdit, error) // workspace/willDeleteFiles -- WillRenameFiles(context.Context, *RenameFilesParams) (*WorkspaceEdit, error) // workspace/willRenameFiles -- ResolveWorkspaceSymbol(context.Context, *WorkspaceSymbol) (*WorkspaceSymbol, error) // workspaceSymbol/resolve -- +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#progress +- Progress(context.Context, *ProgressParams) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#setTrace +- SetTrace(context.Context, *SetTraceParams) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#callHierarchy_incomingCalls +- IncomingCalls(context.Context, *CallHierarchyIncomingCallsParams) ([]CallHierarchyIncomingCall, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#callHierarchy_outgoingCalls +- OutgoingCalls(context.Context, *CallHierarchyOutgoingCallsParams) ([]CallHierarchyOutgoingCall, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeAction_resolve +- ResolveCodeAction(context.Context, *CodeAction) (*CodeAction, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeLens_resolve +- ResolveCodeLens(context.Context, *CodeLens) (*CodeLens, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#completionItem_resolve +- ResolveCompletionItem(context.Context, *CompletionItem) (*CompletionItem, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentLink_resolve +- ResolveDocumentLink(context.Context, *DocumentLink) (*DocumentLink, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#exit +- Exit(context.Context) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#initialize +- Initialize(context.Context, *ParamInitialize) (*InitializeResult, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#initialized +- Initialized(context.Context, *InitializedParams) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlayHint_resolve +- Resolve(context.Context, *InlayHint) (*InlayHint, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocument_didChange +- DidChangeNotebookDocument(context.Context, *DidChangeNotebookDocumentParams) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocument_didClose +- DidCloseNotebookDocument(context.Context, *DidCloseNotebookDocumentParams) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocument_didOpen +- DidOpenNotebookDocument(context.Context, *DidOpenNotebookDocumentParams) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocument_didSave +- DidSaveNotebookDocument(context.Context, *DidSaveNotebookDocumentParams) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#shutdown +- Shutdown(context.Context) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_codeAction +- CodeAction(context.Context, *CodeActionParams) ([]CodeAction, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_codeLens +- CodeLens(context.Context, *CodeLensParams) ([]CodeLens, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_colorPresentation +- ColorPresentation(context.Context, *ColorPresentationParams) ([]ColorPresentation, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_completion +- Completion(context.Context, *CompletionParams) (*CompletionList, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_declaration +- Declaration(context.Context, *DeclarationParams) (*Or_textDocument_declaration, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_definition +- Definition(context.Context, *DefinitionParams) ([]Location, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_diagnostic +- Diagnostic(context.Context, *string) (*string, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_didChange +- DidChange(context.Context, *DidChangeTextDocumentParams) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_didClose +- DidClose(context.Context, *DidCloseTextDocumentParams) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_didOpen +- DidOpen(context.Context, *DidOpenTextDocumentParams) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_didSave +- DidSave(context.Context, *DidSaveTextDocumentParams) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_documentColor +- DocumentColor(context.Context, *DocumentColorParams) ([]ColorInformation, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_documentHighlight +- DocumentHighlight(context.Context, *DocumentHighlightParams) ([]DocumentHighlight, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_documentLink +- DocumentLink(context.Context, *DocumentLinkParams) ([]DocumentLink, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_documentSymbol +- DocumentSymbol(context.Context, *DocumentSymbolParams) ([]interface{}, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_foldingRange +- FoldingRange(context.Context, *FoldingRangeParams) ([]FoldingRange, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_formatting +- Formatting(context.Context, *DocumentFormattingParams) ([]TextEdit, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_hover +- Hover(context.Context, *HoverParams) (*Hover, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_implementation +- Implementation(context.Context, *ImplementationParams) ([]Location, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_inlayHint +- InlayHint(context.Context, *InlayHintParams) ([]InlayHint, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_inlineCompletion +- InlineCompletion(context.Context, *InlineCompletionParams) (*Or_Result_textDocument_inlineCompletion, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_inlineValue +- InlineValue(context.Context, *InlineValueParams) ([]InlineValue, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_linkedEditingRange +- LinkedEditingRange(context.Context, *LinkedEditingRangeParams) (*LinkedEditingRanges, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_moniker +- Moniker(context.Context, *MonikerParams) ([]Moniker, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_onTypeFormatting +- OnTypeFormatting(context.Context, *DocumentOnTypeFormattingParams) ([]TextEdit, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_prepareCallHierarchy +- PrepareCallHierarchy(context.Context, *CallHierarchyPrepareParams) ([]CallHierarchyItem, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_prepareRename +- PrepareRename(context.Context, *PrepareRenameParams) (*PrepareRenameResult, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_prepareTypeHierarchy +- PrepareTypeHierarchy(context.Context, *TypeHierarchyPrepareParams) ([]TypeHierarchyItem, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_rangeFormatting +- RangeFormatting(context.Context, *DocumentRangeFormattingParams) ([]TextEdit, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_rangesFormatting +- RangesFormatting(context.Context, *DocumentRangesFormattingParams) ([]TextEdit, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_references +- References(context.Context, *ReferenceParams) ([]Location, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_rename +- Rename(context.Context, *RenameParams) (*WorkspaceEdit, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_selectionRange +- SelectionRange(context.Context, *SelectionRangeParams) ([]SelectionRange, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_semanticTokens_full +- SemanticTokensFull(context.Context, *SemanticTokensParams) (*SemanticTokens, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_semanticTokens_full_delta +- SemanticTokensFullDelta(context.Context, *SemanticTokensDeltaParams) (interface{}, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_semanticTokens_range +- SemanticTokensRange(context.Context, *SemanticTokensRangeParams) (*SemanticTokens, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_signatureHelp +- SignatureHelp(context.Context, *SignatureHelpParams) (*SignatureHelp, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_typeDefinition +- TypeDefinition(context.Context, *TypeDefinitionParams) ([]Location, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_willSave +- WillSave(context.Context, *WillSaveTextDocumentParams) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_willSaveWaitUntil +- WillSaveWaitUntil(context.Context, *WillSaveTextDocumentParams) ([]TextEdit, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#typeHierarchy_subtypes +- Subtypes(context.Context, *TypeHierarchySubtypesParams) ([]TypeHierarchyItem, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#typeHierarchy_supertypes +- Supertypes(context.Context, *TypeHierarchySupertypesParams) ([]TypeHierarchyItem, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#window_workDoneProgress_cancel +- WorkDoneProgressCancel(context.Context, *WorkDoneProgressCancelParams) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_diagnostic +- DiagnosticWorkspace(context.Context, *WorkspaceDiagnosticParams) (*WorkspaceDiagnosticReport, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_didChangeConfiguration +- DidChangeConfiguration(context.Context, *DidChangeConfigurationParams) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_didChangeWatchedFiles +- DidChangeWatchedFiles(context.Context, *DidChangeWatchedFilesParams) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_didChangeWorkspaceFolders +- DidChangeWorkspaceFolders(context.Context, *DidChangeWorkspaceFoldersParams) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_didCreateFiles +- DidCreateFiles(context.Context, *CreateFilesParams) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_didDeleteFiles +- DidDeleteFiles(context.Context, *DeleteFilesParams) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_didRenameFiles +- DidRenameFiles(context.Context, *RenameFilesParams) error +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_executeCommand +- ExecuteCommand(context.Context, *ExecuteCommandParams) (interface{}, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_symbol +- Symbol(context.Context, *WorkspaceSymbolParams) ([]SymbolInformation, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_willCreateFiles +- WillCreateFiles(context.Context, *CreateFilesParams) (*WorkspaceEdit, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_willDeleteFiles +- WillDeleteFiles(context.Context, *DeleteFilesParams) (*WorkspaceEdit, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_willRenameFiles +- WillRenameFiles(context.Context, *RenameFilesParams) (*WorkspaceEdit, error) +- // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceSymbol_resolve +- ResolveWorkspaceSymbol(context.Context, *WorkspaceSymbol) (*WorkspaceSymbol, error) -} - -func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, r jsonrpc2.Request) (bool, error) { @@ -87748,7 +88974,7 @@ diff -urN a/gopls/internal/server/call_hierarchy.go b/gopls/internal/server/call diff -urN a/gopls/internal/server/code_action.go b/gopls/internal/server/code_action.go --- a/gopls/internal/server/code_action.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/server/code_action.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,275 +0,0 @@ +@@ -1,281 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -87767,6 +88993,7 @@ diff -urN a/gopls/internal/server/code_action.go b/gopls/internal/server/code_ac - "golang.org/x/tools/gopls/internal/mod" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/protocol/command" +- "golang.org/x/tools/gopls/internal/util/slices" - "golang.org/x/tools/internal/event" -) - @@ -87793,27 +89020,24 @@ diff -urN a/gopls/internal/server/code_action.go b/gopls/internal/server/code_ac - - // The Only field of the context specifies which code actions the client wants. - // If Only is empty, assume that the client wants all of the non-explicit code actions. -- var want map[protocol.CodeActionKind]bool -- { -- // Explicit Code Actions are opt-in and shouldn't be returned to the client unless -- // requested using Only. +- want := supportedCodeActions +- if len(params.Context.Only) > 0 { +- want = make(map[protocol.CodeActionKind]bool) +- +- // Explicit Code Actions are opt-in and shouldn't be +- // returned to the client unless requested using Only. - // TODO: Add other CodeLenses such as GoGenerate, RegenerateCgo, etc.. - explicit := map[protocol.CodeActionKind]bool{ - protocol.GoTest: true, - } - -- if len(params.Context.Only) == 0 { -- want = supportedCodeActions -- } else { -- want = make(map[protocol.CodeActionKind]bool) -- for _, only := range params.Context.Only { -- for k, v := range supportedCodeActions { -- if only == k || strings.HasPrefix(string(k), string(only)+".") { -- want[k] = want[k] || v -- } +- for _, only := range params.Context.Only { +- for k, v := range supportedCodeActions { +- if only == k || strings.HasPrefix(string(k), string(only)+".") { +- want[k] = want[k] || v - } -- want[only] = want[only] || explicit[only] - } +- want[only] = want[only] || explicit[only] - } - } - if len(want) == 0 { @@ -87854,12 +89078,6 @@ diff -urN a/gopls/internal/server/code_action.go b/gopls/internal/server/code_ac - return actions, nil - - case file.Go: -- // Don't suggest fixes for generated files, since they are generally -- // not useful and some editors may apply them automatically on save. -- if golang.IsGenerated(ctx, snapshot, uri) { -- return nil, nil -- } -- - actions, err := s.codeActionsMatchingDiagnostics(ctx, uri, snapshot, params.Context.Diagnostics, want) - if err != nil { - return nil, err @@ -87871,6 +89089,20 @@ diff -urN a/gopls/internal/server/code_action.go b/gopls/internal/server/code_ac - } - actions = append(actions, moreActions...) - +- // Don't suggest fixes for generated files, since they are generally +- // not useful and some editors may apply them automatically on save. +- // (Unfortunately there's no reliable way to distinguish fixes from +- // queries, so we must list all kinds of queries here.) +- if golang.IsGenerated(ctx, snapshot, uri) { +- actions = slices.DeleteFunc(actions, func(a protocol.CodeAction) bool { +- switch a.Kind { +- case protocol.GoTest, protocol.GoDoc: +- return false // read-only query +- } +- return true // potential write operation +- }) +- } +- - return actions, nil - - default: @@ -88041,15 +89273,15 @@ diff -urN a/gopls/internal/server/code_lens.go b/gopls/internal/server/code_lens - - "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/golang" +- "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/gopls/internal/mod" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/protocol/command" - "golang.org/x/tools/internal/event" -- "golang.org/x/tools/internal/event/tag" -) - -func (s *server) CodeLens(ctx context.Context, params *protocol.CodeLensParams) ([]protocol.CodeLens, error) { -- ctx, done := event.Start(ctx, "lsp.Server.codeLens", tag.URI.Of(params.TextDocument.URI)) +- ctx, done := event.Start(ctx, "lsp.Server.codeLens", label.URI.Of(params.TextDocument.URI)) - defer done() - - fh, snapshot, release, err := s.fileOf(ctx, params.TextDocument.URI) @@ -88094,7 +89326,7 @@ diff -urN a/gopls/internal/server/code_lens.go b/gopls/internal/server/code_lens diff -urN a/gopls/internal/server/command.go b/gopls/internal/server/command.go --- a/gopls/internal/server/command.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/server/command.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,1431 +0,0 @@ +@@ -1,1441 +0,0 @@ -// Copyright 2020 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -88378,7 +89610,9 @@ diff -urN a/gopls/internal/server/command.go b/gopls/internal/server/command.go - } - wg.Add(1) - go func() { -- c.s.diagnoseSnapshot(snapshot, nil, 0) +- // Diagnosing with the background context ensures new snapshots are fully +- // diagnosed. +- c.s.diagnoseSnapshot(snapshot.BackgroundContext(), snapshot, nil, 0) - release() - wg.Done() - }() @@ -89173,7 +90407,10 @@ diff -urN a/gopls/internal/server/command.go b/gopls/internal/server/command.go - return err - } - defer release() -- c.s.diagnoseSnapshot(snapshot, nil, 0) +- +- // Diagnosing with the background context ensures new snapshots are fully +- // diagnosed. +- c.s.diagnoseSnapshot(snapshot.BackgroundContext(), snapshot, nil, 0) - - affecting := make(map[string]bool, len(result.Entries)) - for _, finding := range result.Findings { @@ -89505,7 +90742,11 @@ diff -urN a/gopls/internal/server/command.go b/gopls/internal/server/command.go - wg.Add(1) - go func() { - defer wg.Done() -- c.s.diagnoseSnapshot(snapshot, nil, 0) +- +- // Use the operation context for diagnosis, rather than +- // snapshot.BackgroundContext, because this operation does not create +- // new snapshots (so they should also be diagnosed by other means). +- c.s.diagnoseSnapshot(ctx, snapshot, nil, 0) - }() - } - wg.Wait() @@ -89518,6 +90759,7 @@ diff -urN a/gopls/internal/server/command.go b/gopls/internal/server/command.go - var summaries []command.View - for _, view := range c.s.session.Views() { - summaries = append(summaries, command.View{ +- ID: view.ID(), - Type: view.Type().String(), - Root: view.Root(), - Folder: view.Folder().Dir, @@ -89544,13 +90786,13 @@ diff -urN a/gopls/internal/server/completion.go b/gopls/internal/server/completi - "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/golang" - "golang.org/x/tools/gopls/internal/golang/completion" +- "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/settings" - "golang.org/x/tools/gopls/internal/telemetry" - "golang.org/x/tools/gopls/internal/template" - "golang.org/x/tools/gopls/internal/work" - "golang.org/x/tools/internal/event" -- "golang.org/x/tools/internal/event/tag" -) - -func (s *server) Completion(ctx context.Context, params *protocol.CompletionParams) (_ *protocol.CompletionList, rerr error) { @@ -89559,7 +90801,7 @@ diff -urN a/gopls/internal/server/completion.go b/gopls/internal/server/completi - recordLatency(ctx, rerr) - }() - -- ctx, done := event.Start(ctx, "lsp.Server.completion", tag.URI.Of(params.TextDocument.URI)) +- ctx, done := event.Start(ctx, "lsp.Server.completion", label.URI.Of(params.TextDocument.URI)) - defer done() - - fh, snapshot, release, err := s.fileOf(ctx, params.TextDocument.URI) @@ -89590,7 +90832,7 @@ diff -urN a/gopls/internal/server/completion.go b/gopls/internal/server/completi - return cl, nil - } - if err != nil { -- event.Error(ctx, "no completions found", err, tag.Position.Of(params.Position)) +- event.Error(ctx, "no completions found", err, label.Position.Of(params.Position)) - } - if candidates == nil { - complEmpty.Inc() @@ -89749,11 +90991,11 @@ diff -urN a/gopls/internal/server/definition.go b/gopls/internal/server/definiti - - "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/golang" +- "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/telemetry" - "golang.org/x/tools/gopls/internal/template" - "golang.org/x/tools/internal/event" -- "golang.org/x/tools/internal/event/tag" -) - -func (s *server) Definition(ctx context.Context, params *protocol.DefinitionParams) (_ []protocol.Location, rerr error) { @@ -89762,7 +91004,7 @@ diff -urN a/gopls/internal/server/definition.go b/gopls/internal/server/definiti - recordLatency(ctx, rerr) - }() - -- ctx, done := event.Start(ctx, "lsp.Server.definition", tag.URI.Of(params.TextDocument.URI)) +- ctx, done := event.Start(ctx, "lsp.Server.definition", label.URI.Of(params.TextDocument.URI)) - defer done() - - // TODO(rfindley): definition requests should be multiplexed across all views. @@ -89782,7 +91024,7 @@ diff -urN a/gopls/internal/server/definition.go b/gopls/internal/server/definiti -} - -func (s *server) TypeDefinition(ctx context.Context, params *protocol.TypeDefinitionParams) ([]protocol.Location, error) { -- ctx, done := event.Start(ctx, "lsp.Server.typeDefinition", tag.URI.Of(params.TextDocument.URI)) +- ctx, done := event.Start(ctx, "lsp.Server.typeDefinition", label.URI.Of(params.TextDocument.URI)) - defer done() - - // TODO(rfindley): type definition requests should be multiplexed across all views. @@ -89801,7 +91043,7 @@ diff -urN a/gopls/internal/server/definition.go b/gopls/internal/server/definiti diff -urN a/gopls/internal/server/diagnostics.go b/gopls/internal/server/diagnostics.go --- a/gopls/internal/server/diagnostics.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/server/diagnostics.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,1000 +0,0 @@ +@@ -1,1006 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -89825,6 +91067,7 @@ diff -urN a/gopls/internal/server/diagnostics.go b/gopls/internal/server/diagnos - "golang.org/x/tools/gopls/internal/cache/metadata" - "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/golang" +- "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/gopls/internal/mod" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/settings" @@ -89833,7 +91076,6 @@ diff -urN a/gopls/internal/server/diagnostics.go b/gopls/internal/server/diagnos - "golang.org/x/tools/gopls/internal/work" - "golang.org/x/tools/internal/event" - "golang.org/x/tools/internal/event/keys" -- "golang.org/x/tools/internal/event/tag" -) - -// fileDiagnostics holds the current state of published diagnostics for a file. @@ -89939,16 +91181,16 @@ diff -urN a/gopls/internal/server/diagnostics.go b/gopls/internal/server/diagnos - go func(snapshot *cache.Snapshot, uris []protocol.DocumentURI) { - defer release() - defer wg.Done() -- s.diagnoseSnapshot(snapshot, uris, snapshot.Options().DiagnosticsDelay) +- s.diagnoseSnapshot(ctx, snapshot, uris, snapshot.Options().DiagnosticsDelay) - s.modificationMu.Lock() - -- // Only remove v from s.viewsToDiagnose if the snapshot is not cancelled. +- // Only remove v from s.viewsToDiagnose if the context is not cancelled. - // This ensures that the snapshot was not cloned before its state was - // fully evaluated, and therefore avoids missing a change that was - // irrelevant to an incomplete snapshot. - // - // See the documentation for s.viewsToDiagnose for details. -- if snapshot.BackgroundContext().Err() == nil && s.viewsToDiagnose[v] <= modID { +- if ctx.Err() == nil && s.viewsToDiagnose[v] <= modID { - delete(s.viewsToDiagnose, v) - } - s.modificationMu.Unlock() @@ -89977,8 +91219,14 @@ diff -urN a/gopls/internal/server/diagnostics.go b/gopls/internal/server/diagnos -// If changedURIs is non-empty, it is a set of recently changed files that -// should be diagnosed immediately, and onDisk reports whether these file -// changes came from a change to on-disk files. --func (s *server) diagnoseSnapshot(snapshot *cache.Snapshot, changedURIs []protocol.DocumentURI, delay time.Duration) { -- ctx := snapshot.BackgroundContext() +-// +-// If the provided context is cancelled, diagnostics may be partially +-// published. Therefore, the provided context should only be cancelled if there +-// will be a subsequent operation to make diagnostics consistent. In general, +-// if an operation creates a new snapshot, it is responsible for ensuring that +-// snapshot (or a subsequent snapshot in the same View) is eventually +-// diagnosed. +-func (s *server) diagnoseSnapshot(ctx context.Context, snapshot *cache.Snapshot, changedURIs []protocol.DocumentURI, delay time.Duration) { - ctx, done := event.Start(ctx, "Server.diagnoseSnapshot", snapshot.Labels()...) - defer done() - @@ -90309,7 +91557,7 @@ diff -urN a/gopls/internal/server/diagnostics.go b/gopls/internal/server/diagnos - // if err is non-nil (though as of today it's OK). - analysisDiags, err = golang.Analyze(ctx, snapshot, toAnalyze, s.progress) - if err != nil { -- event.Error(ctx, "warning: analyzing package", err, append(snapshot.Labels(), tag.Package.Of(keys.Join(maps.Keys(toDiagnose))))...) +- event.Error(ctx, "warning: analyzing package", err, append(snapshot.Labels(), label.Package.Of(keys.Join(maps.Keys(toDiagnose))))...) - return - } - }() @@ -90355,7 +91603,7 @@ diff -urN a/gopls/internal/server/diagnostics.go b/gopls/internal/server/diagnos - for _, mp := range toGCDetail { - gcReports, err := golang.GCOptimizationDetails(ctx, snapshot, mp) - if err != nil { -- event.Error(ctx, "warning: gc details", err, append(snapshot.Labels(), tag.Package.Of(string(mp.ID)))...) +- event.Error(ctx, "warning: gc details", err, append(snapshot.Labels(), label.Package.Of(string(mp.ID)))...) - continue - } - for uri, diags := range gcReports { @@ -90556,7 +91804,7 @@ diff -urN a/gopls/internal/server/diagnostics.go b/gopls/internal/server/diagnos - if ctx.Err() != nil { - return - } else { -- event.Error(ctx, "updateDiagnostics: failed to deliver diagnostics", err, tag.URI.Of(uri)) +- event.Error(ctx, "updateDiagnostics: failed to deliver diagnostics", err, label.URI.Of(uri)) - } - } - } @@ -90572,7 +91820,7 @@ diff -urN a/gopls/internal/server/diagnostics.go b/gopls/internal/server/diagnos - if ctx.Err() != nil { - return - } else { -- event.Error(ctx, "updateDiagnostics: failed to deliver diagnostics", err, tag.URI.Of(uri)) +- event.Error(ctx, "updateDiagnostics: failed to deliver diagnostics", err, label.URI.Of(uri)) - } - } - } @@ -90817,13 +92065,13 @@ diff -urN a/gopls/internal/server/folding_range.go b/gopls/internal/server/foldi - - "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/golang" +- "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/internal/event" -- "golang.org/x/tools/internal/event/tag" -) - -func (s *server) FoldingRange(ctx context.Context, params *protocol.FoldingRangeParams) ([]protocol.FoldingRange, error) { -- ctx, done := event.Start(ctx, "lsp.Server.foldingRange", tag.URI.Of(params.TextDocument.URI)) +- ctx, done := event.Start(ctx, "lsp.Server.foldingRange", label.URI.Of(params.TextDocument.URI)) - defer done() - - fh, snapshot, release, err := s.fileOf(ctx, params.TextDocument.URI) @@ -90870,15 +92118,15 @@ diff -urN a/gopls/internal/server/format.go b/gopls/internal/server/format.go - - "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/golang" +- "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/gopls/internal/mod" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/work" - "golang.org/x/tools/internal/event" -- "golang.org/x/tools/internal/event/tag" -) - -func (s *server) Formatting(ctx context.Context, params *protocol.DocumentFormattingParams) ([]protocol.TextEdit, error) { -- ctx, done := event.Start(ctx, "lsp.Server.formatting", tag.URI.Of(params.TextDocument.URI)) +- ctx, done := event.Start(ctx, "lsp.Server.formatting", label.URI.Of(params.TextDocument.URI)) - defer done() - - fh, snapshot, release, err := s.fileOf(ctx, params.TextDocument.URI) @@ -90900,7 +92148,7 @@ diff -urN a/gopls/internal/server/format.go b/gopls/internal/server/format.go diff -urN a/gopls/internal/server/general.go b/gopls/internal/server/general.go --- a/gopls/internal/server/general.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/server/general.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,685 +0,0 @@ +@@ -1,663 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -91235,7 +92483,7 @@ diff -urN a/gopls/internal/server/general.go b/gopls/internal/server/general.go - // Diagnose the newly created view asynchronously. - ndiagnose.Add(1) - go func() { -- s.diagnoseSnapshot(snapshot, nil, 0) +- s.diagnoseSnapshot(snapshot.BackgroundContext(), snapshot, nil, 0) - <-initialized - release() - ndiagnose.Done() @@ -91363,29 +92611,7 @@ diff -urN a/gopls/internal/server/general.go b/gopls/internal/server/general.go - s.options = opts -} - --func (s *server) newFolder(ctx context.Context, folder protocol.DocumentURI, name string) (*cache.Folder, error) { -- opts := s.Options() -- if opts.ConfigurationSupported { -- scope := string(folder) -- configs, err := s.client.Configuration(ctx, &protocol.ParamConfiguration{ -- Items: []protocol.ConfigurationItem{{ -- ScopeURI: &scope, -- Section: "gopls", -- }}, -- }, -- ) -- if err != nil { -- return nil, fmt.Errorf("failed to get workspace configuration from client (%s): %v", folder, err) -- } -- -- opts = opts.Clone() -- for _, config := range configs { -- if err := s.handleOptionResults(ctx, settings.SetOptions(opts, config)); err != nil { -- return nil, err -- } -- } -- } -- +-func (s *server) newFolder(ctx context.Context, folder protocol.DocumentURI, name string, opts *settings.Options) (*cache.Folder, error) { - env, err := cache.FetchGoEnv(ctx, folder, opts) - if err != nil { - return nil, err @@ -91394,7 +92620,7 @@ diff -urN a/gopls/internal/server/general.go b/gopls/internal/server/general.go - Dir: folder, - Name: name, - Options: opts, -- Env: env, +- Env: *env, - }, nil -} - @@ -91601,14 +92827,14 @@ diff -urN a/gopls/internal/server/highlight.go b/gopls/internal/server/highlight - - "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/golang" +- "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/template" - "golang.org/x/tools/internal/event" -- "golang.org/x/tools/internal/event/tag" -) - -func (s *server) DocumentHighlight(ctx context.Context, params *protocol.DocumentHighlightParams) ([]protocol.DocumentHighlight, error) { -- ctx, done := event.Start(ctx, "lsp.Server.documentHighlight", tag.URI.Of(params.TextDocument.URI)) +- ctx, done := event.Start(ctx, "lsp.Server.documentHighlight", label.URI.Of(params.TextDocument.URI)) - defer done() - - fh, snapshot, release, err := s.fileOf(ctx, params.TextDocument.URI) @@ -91656,13 +92882,13 @@ diff -urN a/gopls/internal/server/hover.go b/gopls/internal/server/hover.go - - "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/golang" +- "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/gopls/internal/mod" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/telemetry" - "golang.org/x/tools/gopls/internal/template" - "golang.org/x/tools/gopls/internal/work" - "golang.org/x/tools/internal/event" -- "golang.org/x/tools/internal/event/tag" -) - -func (s *server) Hover(ctx context.Context, params *protocol.HoverParams) (_ *protocol.Hover, rerr error) { @@ -91671,7 +92897,7 @@ diff -urN a/gopls/internal/server/hover.go b/gopls/internal/server/hover.go - recordLatency(ctx, rerr) - }() - -- ctx, done := event.Start(ctx, "lsp.Server.hover", tag.URI.Of(params.TextDocument.URI)) +- ctx, done := event.Start(ctx, "lsp.Server.hover", label.URI.Of(params.TextDocument.URI)) - defer done() - - fh, snapshot, release, err := s.fileOf(ctx, params.TextDocument.URI) @@ -91707,10 +92933,10 @@ diff -urN a/gopls/internal/server/implementation.go b/gopls/internal/server/impl - - "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/golang" +- "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/telemetry" - "golang.org/x/tools/internal/event" -- "golang.org/x/tools/internal/event/tag" -) - -func (s *server) Implementation(ctx context.Context, params *protocol.ImplementationParams) (_ []protocol.Location, rerr error) { @@ -91719,7 +92945,7 @@ diff -urN a/gopls/internal/server/implementation.go b/gopls/internal/server/impl - recordLatency(ctx, rerr) - }() - -- ctx, done := event.Start(ctx, "lsp.Server.implementation", tag.URI.Of(params.TextDocument.URI)) +- ctx, done := event.Start(ctx, "lsp.Server.implementation", label.URI.Of(params.TextDocument.URI)) - defer done() - - fh, snapshot, release, err := s.fileOf(ctx, params.TextDocument.URI) @@ -91747,14 +92973,14 @@ diff -urN a/gopls/internal/server/inlay_hint.go b/gopls/internal/server/inlay_hi - - "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/golang" +- "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/gopls/internal/mod" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/internal/event" -- "golang.org/x/tools/internal/event/tag" -) - -func (s *server) InlayHint(ctx context.Context, params *protocol.InlayHintParams) ([]protocol.InlayHint, error) { -- ctx, done := event.Start(ctx, "lsp.Server.inlayHint", tag.URI.Of(params.TextDocument.URI)) +- ctx, done := event.Start(ctx, "lsp.Server.inlayHint", label.URI.Of(params.TextDocument.URI)) - defer done() - - fh, snapshot, release, err := s.fileOf(ctx, params.TextDocument.URI) @@ -91774,7 +93000,7 @@ diff -urN a/gopls/internal/server/inlay_hint.go b/gopls/internal/server/inlay_hi diff -urN a/gopls/internal/server/link.go b/gopls/internal/server/link.go --- a/gopls/internal/server/link.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/server/link.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,285 +0,0 @@ +@@ -1,286 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -91798,10 +93024,11 @@ diff -urN a/gopls/internal/server/link.go b/gopls/internal/server/link.go - "golang.org/x/tools/gopls/internal/cache/parsego" - "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/golang" +- "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/util/safetoken" - "golang.org/x/tools/internal/event" -- "golang.org/x/tools/internal/event/tag" +- "mvdan.cc/xurls/v2" -) - -func (s *server) DocumentLink(ctx context.Context, params *protocol.DocumentLinkParams) (links []protocol.DocumentLink, err error) { @@ -91822,7 +93049,7 @@ diff -urN a/gopls/internal/server/link.go b/gopls/internal/server/link.go - } - // Don't return errors for document links. - if err != nil { -- event.Error(ctx, "failed to compute document links", err, tag.URI.Of(fh.URI())) +- event.Error(ctx, "failed to compute document links", err, label.URI.Of(fh.URI())) - return nil, nil // empty result - } - return links, nil // may be empty (for other file types) @@ -91864,7 +93091,7 @@ diff -urN a/gopls/internal/server/link.go b/gopls/internal/server/link.go - } - - // Get all the links that are contained in the comments of the file. -- urlRegexp := snapshot.Options().URLRegexp +- urlRegexp := xurls.Relaxed() - for _, expr := range pm.File.Syntax.Stmt { - comments := expr.Comment() - if comments == nil { @@ -91936,7 +93163,7 @@ diff -urN a/gopls/internal/server/link.go b/gopls/internal/server/link.go - } - } - -- urlRegexp := snapshot.Options().URLRegexp +- urlRegexp := xurls.Relaxed() - - // Gather links found in string literals. - var str []*ast.BasicLit @@ -92480,11 +93707,11 @@ diff -urN a/gopls/internal/server/references.go b/gopls/internal/server/referenc - - "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/golang" +- "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/telemetry" - "golang.org/x/tools/gopls/internal/template" - "golang.org/x/tools/internal/event" -- "golang.org/x/tools/internal/event/tag" -) - -func (s *server) References(ctx context.Context, params *protocol.ReferenceParams) (_ []protocol.Location, rerr error) { @@ -92493,7 +93720,7 @@ diff -urN a/gopls/internal/server/references.go b/gopls/internal/server/referenc - recordLatency(ctx, rerr) - }() - -- ctx, done := event.Start(ctx, "lsp.Server.references", tag.URI.Of(params.TextDocument.URI)) +- ctx, done := event.Start(ctx, "lsp.Server.references", label.URI.Of(params.TextDocument.URI)) - defer done() - - fh, snapshot, release, err := s.fileOf(ctx, params.TextDocument.URI) @@ -92526,13 +93753,13 @@ diff -urN a/gopls/internal/server/rename.go b/gopls/internal/server/rename.go - - "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/golang" +- "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/internal/event" -- "golang.org/x/tools/internal/event/tag" -) - -func (s *server) Rename(ctx context.Context, params *protocol.RenameParams) (*protocol.WorkspaceEdit, error) { -- ctx, done := event.Start(ctx, "lsp.Server.rename", tag.URI.Of(params.TextDocument.URI)) +- ctx, done := event.Start(ctx, "lsp.Server.rename", label.URI.Of(params.TextDocument.URI)) - defer done() - - fh, snapshot, release, err := s.fileOf(ctx, params.TextDocument.URI) @@ -92585,7 +93812,7 @@ diff -urN a/gopls/internal/server/rename.go b/gopls/internal/server/rename.go -// TODO(rfindley): why wouldn't we want to show an error to the user, if the -// user initiated a rename request at the cursor? -func (s *server) PrepareRename(ctx context.Context, params *protocol.PrepareRenameParams) (*protocol.PrepareRenamePlaceholder, error) { -- ctx, done := event.Start(ctx, "lsp.Server.prepareRename", tag.URI.Of(params.TextDocument.URI)) +- ctx, done := event.Start(ctx, "lsp.Server.prepareRename", label.URI.Of(params.TextDocument.URI)) - defer done() - - fh, snapshot, release, err := s.fileOf(ctx, params.TextDocument.URI) @@ -92693,7 +93920,7 @@ diff -urN a/gopls/internal/server/selection_range.go b/gopls/internal/server/sel diff -urN a/gopls/internal/server/semantic.go b/gopls/internal/server/semantic.go --- a/gopls/internal/server/semantic.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/server/semantic.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,53 +0,0 @@ +@@ -1,55 +0,0 @@ -// Copyright 2020 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -92702,14 +93929,13 @@ diff -urN a/gopls/internal/server/semantic.go b/gopls/internal/server/semantic.g - -import ( - "context" -- "fmt" - - "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/golang" +- "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/template" - "golang.org/x/tools/internal/event" -- "golang.org/x/tools/internal/event/tag" -) - -func (s *server) SemanticTokensFull(ctx context.Context, params *protocol.SemanticTokensParams) (*protocol.SemanticTokens, error) { @@ -92721,7 +93947,7 @@ diff -urN a/gopls/internal/server/semantic.go b/gopls/internal/server/semantic.g -} - -func (s *server) semanticTokens(ctx context.Context, td protocol.TextDocumentIdentifier, rng *protocol.Range) (*protocol.SemanticTokens, error) { -- ctx, done := event.Start(ctx, "lsp.Server.semanticTokens", tag.URI.Of(td.URI)) +- ctx, done := event.Start(ctx, "lsp.Server.semanticTokens", label.URI.Of(td.URI)) - defer done() - - fh, snapshot, release, err := s.fileOf(ctx, td.URI) @@ -92730,9 +93956,12 @@ diff -urN a/gopls/internal/server/semantic.go b/gopls/internal/server/semantic.g - } - defer release() - if !snapshot.Options().SemanticTokens { -- // return an error, so if the option changes -- // the client won't remember the wrong answer -- return nil, fmt.Errorf("semantictokens are disabled") +- // Note: returning new(protocol.SemanticTokens) is necessary here to +- // invalidate semantic tokens in VS Code (and perhaps other editors). +- // Previously, an error was returned here to achieve the same effect, but +- // that had the side effect of very noisy "semantictokens are disabled" +- // logs on every keystroke. +- return new(protocol.SemanticTokens), nil - } - - switch snapshot.FileKind(fh) { @@ -92750,7 +93979,7 @@ diff -urN a/gopls/internal/server/semantic.go b/gopls/internal/server/semantic.g diff -urN a/gopls/internal/server/server.go b/gopls/internal/server/server.go --- a/gopls/internal/server/server.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/server/server.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,398 +0,0 @@ +@@ -1,415 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -92781,6 +94010,7 @@ diff -urN a/gopls/internal/server/server.go b/gopls/internal/server/server.go - "golang.org/x/tools/gopls/internal/progress" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/settings" +- "golang.org/x/tools/gopls/internal/util/bug" - "golang.org/x/tools/internal/event" -) - @@ -93016,7 +94246,7 @@ diff -urN a/gopls/internal/server/server.go b/gopls/internal/server/server.go - - secret := "/gopls/" + base64.RawURLEncoding.EncodeToString(token) - webMux := http.NewServeMux() -- rootMux.Handle(secret+"/", http.StripPrefix(secret, webMux)) +- rootMux.Handle(secret+"/", withPanicHandler(http.StripPrefix(secret, webMux))) - - webServer := &http.Server{Addr: listener.Addr().String(), Handler: rootMux} - go func() { @@ -93149,10 +94379,26 @@ diff -urN a/gopls/internal/server/server.go b/gopls/internal/server/server.go - url2.Fragment = fragment - return protocol.URI(url2.String()) -} +- +-// withPanicHandler wraps an HTTP handler with telemetry-reporting of +-// panics that would otherwise be silently recovered by the net/http +-// root handler. +-func withPanicHandler(h http.Handler) http.HandlerFunc { +- return func(w http.ResponseWriter, req *http.Request) { +- panicked := true +- defer func() { +- if panicked { +- bug.Report("panic in HTTP handler") +- } +- }() +- h.ServeHTTP(w, req) +- panicked = false +- } +-} diff -urN a/gopls/internal/server/signature_help.go b/gopls/internal/server/signature_help.go --- a/gopls/internal/server/signature_help.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/server/signature_help.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,40 +0,0 @@ +@@ -1,48 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -93164,13 +94410,13 @@ diff -urN a/gopls/internal/server/signature_help.go b/gopls/internal/server/sign - - "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/golang" +- "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/internal/event" -- "golang.org/x/tools/internal/event/tag" -) - -func (s *server) SignatureHelp(ctx context.Context, params *protocol.SignatureHelpParams) (*protocol.SignatureHelp, error) { -- ctx, done := event.Start(ctx, "lsp.Server.signatureHelp", tag.URI.Of(params.TextDocument.URI)) +- ctx, done := event.Start(ctx, "lsp.Server.signatureHelp", label.URI.Of(params.TextDocument.URI)) - defer done() - - fh, snapshot, release, err := s.fileOf(ctx, params.TextDocument.URI) @@ -93185,8 +94431,16 @@ diff -urN a/gopls/internal/server/signature_help.go b/gopls/internal/server/sign - - info, activeParameter, err := golang.SignatureHelp(ctx, snapshot, fh, params.Position) - if err != nil { -- event.Error(ctx, "no signature help", err, tag.Position.Of(params.Position)) -- return nil, nil // sic? There could be many reasons for failure. +- // TODO(rfindley): is this correct? Apparently, returning an error from +- // signatureHelp is distracting in some editors, though I haven't confirmed +- // that recently. +- // +- // It's unclear whether we still need to avoid returning this error result. +- event.Error(ctx, "signature help failed", err, label.Position.Of(params.Position)) +- return nil, nil +- } +- if info == nil { +- return nil, nil - } - return &protocol.SignatureHelp{ - Signatures: []protocol.SignatureInformation{*info}, @@ -93208,14 +94462,14 @@ diff -urN a/gopls/internal/server/symbols.go b/gopls/internal/server/symbols.go - - "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/golang" +- "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/template" - "golang.org/x/tools/internal/event" -- "golang.org/x/tools/internal/event/tag" -) - -func (s *server) DocumentSymbol(ctx context.Context, params *protocol.DocumentSymbolParams) ([]any, error) { -- ctx, done := event.Start(ctx, "lsp.Server.documentSymbol", tag.URI.Of(params.TextDocument.URI)) +- ctx, done := event.Start(ctx, "lsp.Server.documentSymbol", label.URI.Of(params.TextDocument.URI)) - defer done() - - fh, snapshot, release, err := s.fileOf(ctx, params.TextDocument.URI) @@ -93281,9 +94535,9 @@ diff -urN a/gopls/internal/server/text_synchronization.go b/gopls/internal/serve - "golang.org/x/tools/gopls/internal/cache" - "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/golang" +- "golang.org/x/tools/gopls/internal/label" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/internal/event" -- "golang.org/x/tools/internal/event/tag" - "golang.org/x/tools/internal/jsonrpc2" - "golang.org/x/tools/internal/xcontext" -) @@ -93357,7 +94611,7 @@ diff -urN a/gopls/internal/server/text_synchronization.go b/gopls/internal/serve -} - -func (s *server) DidOpen(ctx context.Context, params *protocol.DidOpenTextDocumentParams) error { -- ctx, done := event.Start(ctx, "lsp.Server.didOpen", tag.URI.Of(params.TextDocument.URI)) +- ctx, done := event.Start(ctx, "lsp.Server.didOpen", label.URI.Of(params.TextDocument.URI)) - defer done() - - uri := params.TextDocument.URI @@ -93386,7 +94640,7 @@ diff -urN a/gopls/internal/server/text_synchronization.go b/gopls/internal/serve -} - -func (s *server) DidChange(ctx context.Context, params *protocol.DidChangeTextDocumentParams) error { -- ctx, done := event.Start(ctx, "lsp.Server.didChange", tag.URI.Of(params.TextDocument.URI)) +- ctx, done := event.Start(ctx, "lsp.Server.didChange", label.URI.Of(params.TextDocument.URI)) - defer done() - - uri := params.TextDocument.URI @@ -93455,7 +94709,7 @@ diff -urN a/gopls/internal/server/text_synchronization.go b/gopls/internal/serve -} - -func (s *server) DidSave(ctx context.Context, params *protocol.DidSaveTextDocumentParams) error { -- ctx, done := event.Start(ctx, "lsp.Server.didSave", tag.URI.Of(params.TextDocument.URI)) +- ctx, done := event.Start(ctx, "lsp.Server.didSave", label.URI.Of(params.TextDocument.URI)) - defer done() - - c := file.Modification{ @@ -93469,7 +94723,7 @@ diff -urN a/gopls/internal/server/text_synchronization.go b/gopls/internal/serve -} - -func (s *server) DidClose(ctx context.Context, params *protocol.DidCloseTextDocumentParams) error { -- ctx, done := event.Start(ctx, "lsp.Server.didClose", tag.URI.Of(params.TextDocument.URI)) +- ctx, done := event.Start(ctx, "lsp.Server.didClose", label.URI.Of(params.TextDocument.URI)) - defer done() - - return s.didModifyFiles(ctx, []file.Modification{ @@ -93838,7 +95092,7 @@ diff -urN a/gopls/internal/server/unimplemented.go b/gopls/internal/server/unimp diff -urN a/gopls/internal/server/workspace.go b/gopls/internal/server/workspace.go --- a/gopls/internal/server/workspace.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/server/workspace.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,104 +0,0 @@ +@@ -1,134 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -93848,10 +95102,12 @@ diff -urN a/gopls/internal/server/workspace.go b/gopls/internal/server/workspace -import ( - "context" - "fmt" +- "reflect" - "sync" - - "golang.org/x/tools/gopls/internal/cache" - "golang.org/x/tools/gopls/internal/protocol" +- "golang.org/x/tools/gopls/internal/settings" - "golang.org/x/tools/internal/event" -) - @@ -93878,7 +95134,11 @@ diff -urN a/gopls/internal/server/workspace.go b/gopls/internal/server/workspace - if state < serverInitialized { - return nil, nil, fmt.Errorf("addView called before server initialized") - } -- folder, err := s.newFolder(ctx, dir, name) +- opts, err := s.fetchFolderOptions(ctx, dir) +- if err != nil { +- return nil, nil, err +- } +- folder, err := s.newFolder(ctx, dir, name, opts) - if err != nil { - return nil, nil, err - } @@ -93909,15 +95169,39 @@ diff -urN a/gopls/internal/server/workspace.go b/gopls/internal/server/workspace - s.SetOptions(options) - - // Collect options for all workspace folders. -- seen := make(map[protocol.DocumentURI]bool) -- var newFolders []*cache.Folder -- for _, view := range s.session.Views() { +- // If none have changed, this is a no op. +- folderOpts := make(map[protocol.DocumentURI]*settings.Options) +- changed := false +- // The set of views is implicitly guarded by the fact that gopls processes +- // didChange notifications synchronously. +- // +- // TODO(rfindley): investigate this assumption: perhaps we should hold viewMu +- // here. +- views := s.session.Views() +- for _, view := range views { - folder := view.Folder() -- if seen[folder.Dir] { +- if folderOpts[folder.Dir] != nil { - continue - } -- seen[folder.Dir] = true -- newFolder, err := s.newFolder(ctx, folder.Dir, folder.Name) +- opts, err := s.fetchFolderOptions(ctx, folder.Dir) +- if err != nil { +- return err +- } +- +- if !reflect.DeepEqual(folder.Options, opts) { +- changed = true +- } +- folderOpts[folder.Dir] = opts +- } +- if !changed { +- return nil +- } +- +- var newFolders []*cache.Folder +- for _, view := range views { +- folder := view.Folder() +- opts := folderOpts[folder.Dir] +- newFolder, err := s.newFolder(ctx, folder.Dir, folder.Name, opts) - if err != nil { - return err - } @@ -93988,11 +95272,93 @@ diff -urN a/gopls/internal/server/workspace_symbol.go b/gopls/internal/server/wo - } - return golang.WorkspaceSymbols(ctx, matcher, style, snapshots, params.Query) -} -diff -urN a/gopls/internal/settings/analyzer.go b/gopls/internal/settings/analyzer.go ---- a/gopls/internal/settings/analyzer.go 2000-01-01 00:00:00.000000000 -0000 -+++ b/gopls/internal/settings/analyzer.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,53 +0,0 @@ --// Copyright 2023 The Go Authors. All rights reserved. +diff -urN a/gopls/internal/settings/analysis_119.go b/gopls/internal/settings/analysis_119.go +--- a/gopls/internal/settings/analysis_119.go 2000-01-01 00:00:00.000000000 -0000 ++++ b/gopls/internal/settings/analysis_119.go 1970-01-01 00:00:00.000000000 +0000 +@@ -1,10 +0,0 @@ +-// Copyright 2021 The Go Authors. All rights reserved. +-// Use of this source code is governed by a BSD-style +-// license that can be found in the LICENSE file. +- +-//go:build !go1.20 +-// +build !go1.20 +- +-package settings +- +-const StaticcheckSupported = false +diff -urN a/gopls/internal/settings/analysis_120.go b/gopls/internal/settings/analysis_120.go +--- a/gopls/internal/settings/analysis_120.go 2000-01-01 00:00:00.000000000 -0000 ++++ b/gopls/internal/settings/analysis_120.go 1970-01-01 00:00:00.000000000 +0000 +@@ -1,64 +0,0 @@ +-// Copyright 2019 The Go Authors. All rights reserved. +-// Use of this source code is governed by a BSD-style +-// license that can be found in the LICENSE file. +- +-//go:build go1.20 +-// +build go1.20 +- +-package settings +- +-import ( +- "golang.org/x/tools/gopls/internal/protocol" +- "honnef.co/go/tools/analysis/lint" +- "honnef.co/go/tools/quickfix" +- "honnef.co/go/tools/simple" +- "honnef.co/go/tools/staticcheck" +- "honnef.co/go/tools/stylecheck" +-) +- +-const StaticcheckSupported = true +- +-func init() { +- mapSeverity := func(severity lint.Severity) protocol.DiagnosticSeverity { +- switch severity { +- case lint.SeverityError: +- return protocol.SeverityError +- case lint.SeverityDeprecated: +- // TODO(dh): in LSP, deprecated is a tag, not a severity. +- // We'll want to support this once we enable SA5011. +- return protocol.SeverityWarning +- case lint.SeverityWarning: +- return protocol.SeverityWarning +- case lint.SeverityInfo: +- return protocol.SeverityInformation +- case lint.SeverityHint: +- return protocol.SeverityHint +- default: +- return protocol.SeverityWarning +- } +- } +- add := func(analyzers []*lint.Analyzer, skip map[string]struct{}) { +- for _, a := range analyzers { +- if _, ok := skip[a.Analyzer.Name]; ok { +- continue +- } +- +- StaticcheckAnalyzers[a.Analyzer.Name] = &Analyzer{ +- analyzer: a.Analyzer, +- enabled: !a.Doc.NonDefault, +- severity: mapSeverity(a.Doc.Severity), +- } +- } +- } +- +- add(simple.Analyzers, nil) +- add(staticcheck.Analyzers, map[string]struct{}{ +- // This check conflicts with the vet printf check (golang/go#34494). +- "SA5009": {}, +- // This check relies on facts from dependencies, which +- // we don't currently compute. +- "SA5011": {}, +- }) +- add(stylecheck.Analyzers, nil) +- add(quickfix.Analyzers, nil) +-} +diff -urN a/gopls/internal/settings/analysis.go b/gopls/internal/settings/analysis.go +--- a/gopls/internal/settings/analysis.go 2000-01-01 00:00:00.000000000 -0000 ++++ b/gopls/internal/settings/analysis.go 1970-01-01 00:00:00.000000000 +0000 +@@ -1,185 +0,0 @@ +-// Copyright 2024 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - @@ -94000,55 +95366,187 @@ diff -urN a/gopls/internal/settings/analyzer.go b/gopls/internal/settings/analyz - -import ( - "golang.org/x/tools/go/analysis" +- "golang.org/x/tools/go/analysis/passes/appends" +- "golang.org/x/tools/go/analysis/passes/asmdecl" +- "golang.org/x/tools/go/analysis/passes/assign" +- "golang.org/x/tools/go/analysis/passes/atomic" +- "golang.org/x/tools/go/analysis/passes/atomicalign" +- "golang.org/x/tools/go/analysis/passes/bools" +- "golang.org/x/tools/go/analysis/passes/buildtag" +- "golang.org/x/tools/go/analysis/passes/cgocall" +- "golang.org/x/tools/go/analysis/passes/composite" +- "golang.org/x/tools/go/analysis/passes/copylock" +- "golang.org/x/tools/go/analysis/passes/deepequalerrors" +- "golang.org/x/tools/go/analysis/passes/defers" +- "golang.org/x/tools/go/analysis/passes/directive" +- "golang.org/x/tools/go/analysis/passes/errorsas" +- "golang.org/x/tools/go/analysis/passes/fieldalignment" +- "golang.org/x/tools/go/analysis/passes/httpresponse" +- "golang.org/x/tools/go/analysis/passes/ifaceassert" +- "golang.org/x/tools/go/analysis/passes/loopclosure" +- "golang.org/x/tools/go/analysis/passes/lostcancel" +- "golang.org/x/tools/go/analysis/passes/nilfunc" +- "golang.org/x/tools/go/analysis/passes/nilness" +- "golang.org/x/tools/go/analysis/passes/printf" +- "golang.org/x/tools/go/analysis/passes/shadow" +- "golang.org/x/tools/go/analysis/passes/shift" +- "golang.org/x/tools/go/analysis/passes/slog" +- "golang.org/x/tools/go/analysis/passes/sortslice" +- "golang.org/x/tools/go/analysis/passes/stdmethods" +- "golang.org/x/tools/go/analysis/passes/stdversion" +- "golang.org/x/tools/go/analysis/passes/stringintconv" +- "golang.org/x/tools/go/analysis/passes/structtag" +- "golang.org/x/tools/go/analysis/passes/testinggoroutine" +- "golang.org/x/tools/go/analysis/passes/tests" +- "golang.org/x/tools/go/analysis/passes/timeformat" +- "golang.org/x/tools/go/analysis/passes/unmarshal" +- "golang.org/x/tools/go/analysis/passes/unreachable" +- "golang.org/x/tools/go/analysis/passes/unsafeptr" +- "golang.org/x/tools/go/analysis/passes/unusedresult" +- "golang.org/x/tools/go/analysis/passes/unusedwrite" +- "golang.org/x/tools/gopls/internal/analysis/deprecated" +- "golang.org/x/tools/gopls/internal/analysis/embeddirective" +- "golang.org/x/tools/gopls/internal/analysis/fillreturns" +- "golang.org/x/tools/gopls/internal/analysis/infertypeargs" +- "golang.org/x/tools/gopls/internal/analysis/nonewvars" +- "golang.org/x/tools/gopls/internal/analysis/noresultvalues" +- "golang.org/x/tools/gopls/internal/analysis/simplifycompositelit" +- "golang.org/x/tools/gopls/internal/analysis/simplifyrange" +- "golang.org/x/tools/gopls/internal/analysis/simplifyslice" +- "golang.org/x/tools/gopls/internal/analysis/stubmethods" +- "golang.org/x/tools/gopls/internal/analysis/undeclaredname" +- "golang.org/x/tools/gopls/internal/analysis/unusedparams" +- "golang.org/x/tools/gopls/internal/analysis/unusedvariable" +- "golang.org/x/tools/gopls/internal/analysis/useany" - "golang.org/x/tools/gopls/internal/protocol" -) - --// Analyzer augments a go/analysis analyzer with additional LSP configuration. +-// Analyzer augments a [analysis.Analyzer] with additional LSP configuration. +-// +-// Analyzers are immutable, since they are shared across multiple LSP sessions. -type Analyzer struct { -- Analyzer *analysis.Analyzer +- analyzer *analysis.Analyzer +- enabled bool +- actionKinds []protocol.CodeActionKind +- severity protocol.DiagnosticSeverity +- tags []protocol.DiagnosticTag +-} - -- // Enabled reports whether the analyzer is enabled. This value can be -- // configured per-analysis in user settings. For staticcheck analyzers, -- // the value of the Staticcheck setting overrides this field. -- // -- // Most clients should use the IsEnabled method. -- Enabled bool +-// Analyzer returns the [analysis.Analyzer] that this Analyzer wraps. +-func (a *Analyzer) Analyzer() *analysis.Analyzer { return a.analyzer } - -- // ActionKinds is the set of kinds of code action this analyzer produces. -- // If empty, the set is just QuickFix. -- ActionKinds []protocol.CodeActionKind +-// EnabledByDefault reports whether the analyzer is enabled by default for all sessions. +-// This value can be configured per-analysis in user settings. +-func (a *Analyzer) EnabledByDefault() bool { return a.enabled } - -- // Severity is the severity set for diagnostics reported by this -- // analyzer. If left unset it defaults to Warning. -- // -- // Note: diagnostics with severity protocol.SeverityHint do not show up in -- // the VS Code "problems" tab. -- Severity protocol.DiagnosticSeverity +-// ActionKinds is the set of kinds of code action this analyzer produces. +-// +-// If left unset, it defaults to QuickFix. +-// TODO(rfindley): revisit. +-func (a *Analyzer) ActionKinds() []protocol.CodeActionKind { return a.actionKinds } - -- // Tag is extra tags (unnecessary, deprecated, etc) for diagnostics -- // reported by this analyzer. -- Tag []protocol.DiagnosticTag --} +-// Severity is the severity set for diagnostics reported by this +-// analyzer. If left unset it defaults to Warning. +-// +-// Note: diagnostics with severity protocol.SeverityHint do not show up in +-// the VS Code "problems" tab. +-func (a *Analyzer) Severity() protocol.DiagnosticSeverity { return a.severity } - --func (a *Analyzer) String() string { return a.Analyzer.String() } +-// Tags is extra tags (unnecessary, deprecated, etc) for diagnostics +-// reported by this analyzer. +-func (a *Analyzer) Tags() []protocol.DiagnosticTag { return a.tags } - --// IsEnabled reports whether this analyzer is enabled by the given options. --func (a Analyzer) IsEnabled(options *Options) bool { -- // Staticcheck analyzers can only be enabled when staticcheck is on. -- if _, ok := options.StaticcheckAnalyzers[a.Analyzer.Name]; ok { -- if !options.Staticcheck { -- return false -- } +-// String returns the name of this analyzer. +-func (a *Analyzer) String() string { return a.analyzer.String() } +- +-// DefaultAnalyzers holds the set of Analyzers available to all gopls sessions, +-// independent of build version, keyed by analyzer name. +-var DefaultAnalyzers = make(map[string]*Analyzer) // initialized below +- +-func init() { +- // The traditional vet suite: +- analyzers := []*Analyzer{ +- {analyzer: appends.Analyzer, enabled: true}, +- {analyzer: asmdecl.Analyzer, enabled: true}, +- {analyzer: assign.Analyzer, enabled: true}, +- {analyzer: atomic.Analyzer, enabled: true}, +- {analyzer: bools.Analyzer, enabled: true}, +- {analyzer: buildtag.Analyzer, enabled: true}, +- {analyzer: cgocall.Analyzer, enabled: true}, +- {analyzer: composite.Analyzer, enabled: true}, +- {analyzer: copylock.Analyzer, enabled: true}, +- {analyzer: defers.Analyzer, enabled: true}, +- {analyzer: deprecated.Analyzer, enabled: true, severity: protocol.SeverityHint, tags: []protocol.DiagnosticTag{protocol.Deprecated}}, +- {analyzer: directive.Analyzer, enabled: true}, +- {analyzer: errorsas.Analyzer, enabled: true}, +- {analyzer: httpresponse.Analyzer, enabled: true}, +- {analyzer: ifaceassert.Analyzer, enabled: true}, +- {analyzer: loopclosure.Analyzer, enabled: true}, +- {analyzer: lostcancel.Analyzer, enabled: true}, +- {analyzer: nilfunc.Analyzer, enabled: true}, +- {analyzer: printf.Analyzer, enabled: true}, +- {analyzer: shift.Analyzer, enabled: true}, +- {analyzer: slog.Analyzer, enabled: true}, +- {analyzer: stdmethods.Analyzer, enabled: true}, +- {analyzer: stringintconv.Analyzer, enabled: true}, +- {analyzer: structtag.Analyzer, enabled: true}, +- {analyzer: tests.Analyzer, enabled: true}, +- {analyzer: unmarshal.Analyzer, enabled: true}, +- {analyzer: unreachable.Analyzer, enabled: true}, +- {analyzer: unsafeptr.Analyzer, enabled: true}, +- {analyzer: unusedresult.Analyzer, enabled: true}, +- +- // Non-vet analyzers: +- // - some (nilness, unusedwrite) use go/ssa; +- // - some (unusedwrite) report bad code but not always a bug, +- // so are not suitable for vet. +- {analyzer: atomicalign.Analyzer, enabled: true}, +- {analyzer: deepequalerrors.Analyzer, enabled: true}, +- {analyzer: fieldalignment.Analyzer, enabled: false}, +- {analyzer: nilness.Analyzer, enabled: true}, +- {analyzer: shadow.Analyzer, enabled: false}, +- {analyzer: sortslice.Analyzer, enabled: true}, +- {analyzer: testinggoroutine.Analyzer, enabled: true}, +- {analyzer: unusedparams.Analyzer, enabled: true}, +- {analyzer: unusedwrite.Analyzer, enabled: true}, +- {analyzer: useany.Analyzer, enabled: false}, +- {analyzer: infertypeargs.Analyzer, enabled: true, severity: protocol.SeverityHint}, +- {analyzer: timeformat.Analyzer, enabled: true}, +- {analyzer: embeddirective.Analyzer, enabled: true}, +- +- // gofmt -s suite: +- {analyzer: simplifycompositelit.Analyzer, enabled: true, actionKinds: []protocol.CodeActionKind{protocol.SourceFixAll, protocol.QuickFix}}, +- {analyzer: simplifyrange.Analyzer, enabled: true, actionKinds: []protocol.CodeActionKind{protocol.SourceFixAll, protocol.QuickFix}}, +- {analyzer: simplifyslice.Analyzer, enabled: true, actionKinds: []protocol.CodeActionKind{protocol.SourceFixAll, protocol.QuickFix}}, +- {analyzer: stdversion.Analyzer, enabled: true}, +- +- // Type error analyzers. +- // These analyzers enrich go/types errors with suggested fixes. +- {analyzer: fillreturns.Analyzer, enabled: true}, +- {analyzer: nonewvars.Analyzer, enabled: true}, +- {analyzer: noresultvalues.Analyzer, enabled: true}, +- {analyzer: stubmethods.Analyzer, enabled: true}, +- {analyzer: undeclaredname.Analyzer, enabled: true}, +- // TODO(rfindley): why isn't the 'unusedvariable' analyzer enabled, if it +- // is only enhancing type errors with suggested fixes? +- // +- // In particular, enabling this analyzer could cause unused variables to be +- // greyed out, (due to the 'deletions only' fix). That seems like a nice UI +- // feature. +- {analyzer: unusedvariable.Analyzer, enabled: false}, - } -- if enabled, ok := options.Analyses[a.Analyzer.Name]; ok { -- return enabled +- for _, analyzer := range analyzers { +- DefaultAnalyzers[analyzer.analyzer.Name] = analyzer - } -- return a.Enabled -} +- +-// StaticcheckAnalzyers describes available Staticcheck analyzers, keyed by +-// analyzer name. +-var StaticcheckAnalyzers = make(map[string]*Analyzer) // written by analysis_.go diff -urN a/gopls/internal/settings/api_json.go b/gopls/internal/settings/api_json.go --- a/gopls/internal/settings/api_json.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/settings/api_json.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,1318 +0,0 @@ +@@ -1,1310 +0,0 @@ -// Code generated by "golang.org/x/tools/gopls/doc/generate"; DO NOT EDIT. - -package settings @@ -94101,14 +95599,6 @@ diff -urN a/gopls/internal/settings/api_json.go b/gopls/internal/settings/api_js - 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", @@ -94248,7 +95738,7 @@ diff -urN a/gopls/internal/settings/api_json.go b/gopls/internal/settings/api_js - { - Name: "symbolScope", - Type: "enum", -- Doc: "symbolScope controls which packages are searched for workspace/symbol\nrequests. The default value, \"workspace\", searches only workspace\npackages. The legacy behavior, \"all\", causes all loaded packages to be\nsearched, including dependencies; this is more expensive and may return\nunwanted results.\n", +- Doc: "symbolScope controls which packages are searched for workspace/symbol\nrequests. When the scope is \"workspace\", gopls searches only workspace\npackages. When the scope is \"all\", gopls searches all loaded packages,\nincluding dependencies and the standard library.\n", - EnumValues: []EnumValue{ - { - Value: "\"all\"", @@ -94406,7 +95896,7 @@ diff -urN a/gopls/internal/settings/api_json.go b/gopls/internal/settings/api_js - }, - { - Name: "\"printf\"", -- Doc: "check consistency of Printf format strings and arguments\n\nThe check applies to calls of the formatting functions such as\n[fmt.Printf] and [fmt.Sprintf], as well as any detected wrappers of\nthose functions.\n\nIn this example, the %d format operator requires an integer operand:\n\n\tfmt.Printf(\"%d\", \"hello\") // fmt.Printf format %d has arg \"hello\" of wrong type string\n\nSee the documentation of the fmt package for the complete set of\nformat operators and their operand types.\n\nTo enable printf checking on a function that is not found by this\nanalyzer's heuristics (for example, because control is obscured by\ndynamic method calls), insert a bogus call:\n\n\tfunc MyPrintf(format string, args ...any) {\n\t\tif false {\n\t\t\t_ = fmt.Sprintf(format, args...) // enable printf checker\n\t\t}\n\t\t...\n\t}\n\nThe -funcs flag specifies a comma-separated list of names of additional\nknown formatting functions or methods. If the name contains a period,\nit must denote a specific function using one of the following forms:\n\n\tdir/pkg.Function\n\tdir/pkg.Type.Method\n\t(*dir/pkg.Type).Method\n\nOtherwise the name is interpreted as a case-insensitive unqualified\nidentifier such as \"errorf\". Either way, if a listed name ends in f, the\nfunction is assumed to be Printf-like, taking a format string before the\nargument list. Otherwise it is assumed to be Print-like, taking a list\nof arguments with no format string.", +- Doc: "check consistency of Printf format strings and arguments\n\nThe check applies to calls of the formatting functions such as\n[fmt.Printf] and [fmt.Sprintf], as well as any detected wrappers of\nthose functions such as [log.Printf]. It reports a variety of\nmistakes such as syntax errors in the format string and mismatches\n(of number and type) between the verbs and their arguments.\n\nSee the documentation of the fmt package for the complete set of\nformat operators and their operand types.", - Default: "true", - }, - { @@ -94726,8 +96216,8 @@ diff -urN a/gopls/internal/settings/api_json.go b/gopls/internal/settings/api_js - { - Name: "semanticTokens", - Type: "bool", -- Doc: "semanticTokens controls whether the LSP server will send\nsemantic tokens to the client.\n", -- Default: "false", +- Doc: "semanticTokens controls whether the LSP server will send\nsemantic tokens to the client. If false, gopls will send empty semantic\ntokens.\n", +- Default: "true", - Status: "experimental", - Hierarchy: "ui", - }, @@ -94975,7 +96465,7 @@ diff -urN a/gopls/internal/settings/api_json.go b/gopls/internal/settings/api_js - Command: "gopls.views", - Title: "List current Views on the server.", - Doc: "This command is intended for use by gopls tests only.", -- ResultDoc: "[]{\n\t\"Type\": string,\n\t\"Root\": string,\n\t\"Folder\": string,\n\t\"EnvOverlay\": []string,\n}", +- ResultDoc: "[]{\n\t\"ID\": string,\n\t\"Type\": string,\n\t\"Root\": string,\n\t\"Folder\": string,\n\t\"EnvOverlay\": []string,\n}", - }, - { - Command: "gopls.workspace_stats", @@ -95190,7 +96680,7 @@ diff -urN a/gopls/internal/settings/api_json.go b/gopls/internal/settings/api_js - }, - { - Name: "printf", -- Doc: "check consistency of Printf format strings and arguments\n\nThe check applies to calls of the formatting functions such as\n[fmt.Printf] and [fmt.Sprintf], as well as any detected wrappers of\nthose functions.\n\nIn this example, the %d format operator requires an integer operand:\n\n\tfmt.Printf(\"%d\", \"hello\") // fmt.Printf format %d has arg \"hello\" of wrong type string\n\nSee the documentation of the fmt package for the complete set of\nformat operators and their operand types.\n\nTo enable printf checking on a function that is not found by this\nanalyzer's heuristics (for example, because control is obscured by\ndynamic method calls), insert a bogus call:\n\n\tfunc MyPrintf(format string, args ...any) {\n\t\tif false {\n\t\t\t_ = fmt.Sprintf(format, args...) // enable printf checker\n\t\t}\n\t\t...\n\t}\n\nThe -funcs flag specifies a comma-separated list of names of additional\nknown formatting functions or methods. If the name contains a period,\nit must denote a specific function using one of the following forms:\n\n\tdir/pkg.Function\n\tdir/pkg.Type.Method\n\t(*dir/pkg.Type).Method\n\nOtherwise the name is interpreted as a case-insensitive unqualified\nidentifier such as \"errorf\". Either way, if a listed name ends in f, the\nfunction is assumed to be Printf-like, taking a format string before the\nargument list. Otherwise it is assumed to be Print-like, taking a list\nof arguments with no format string.", +- Doc: "check consistency of Printf format strings and arguments\n\nThe check applies to calls of the formatting functions such as\n[fmt.Printf] and [fmt.Sprintf], as well as any detected wrappers of\nthose functions such as [log.Printf]. It reports a variety of\nmistakes such as syntax errors in the format string and mismatches\n(of number and type) between the verbs and their arguments.\n\nSee the documentation of the fmt package for the complete set of\nformat operators and their operand types.", - URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/printf", - Default: true, - }, @@ -95370,7 +96860,7 @@ diff -urN a/gopls/internal/settings/api_json.go b/gopls/internal/settings/api_js diff -urN a/gopls/internal/settings/default.go b/gopls/internal/settings/default.go --- a/gopls/internal/settings/default.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/settings/default.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,136 +0,0 @@ +@@ -1,132 +0,0 @@ -// Copyright 2023 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -95479,6 +96969,7 @@ diff -urN a/gopls/internal/settings/default.go b/gopls/internal/settings/default - string(command.Vendor): true, - // TODO(hyangah): enable command.RunGovulncheck. - }, +- SemanticTokens: true, - }, - }, - InternalOptions: InternalOptions{ @@ -95492,11 +96983,6 @@ diff -urN a/gopls/internal/settings/default.go b/gopls/internal/settings/default - IncludeReplaceInWorkspace: false, - ZeroConfig: true, - }, -- Hooks: Hooks{ -- URLRegexp: urlRegexp(), -- DefaultAnalyzers: analyzers(), -- StaticcheckAnalyzers: map[string]*Analyzer{}, -- }, - } - }) - options := defaultOptions.Clone() @@ -95507,6 +96993,165 @@ diff -urN a/gopls/internal/settings/default.go b/gopls/internal/settings/default - } - return options -} +diff -urN a/gopls/internal/settings/gofumpt_119.go b/gopls/internal/settings/gofumpt_119.go +--- a/gopls/internal/settings/gofumpt_119.go 2000-01-01 00:00:00.000000000 -0000 ++++ b/gopls/internal/settings/gofumpt_119.go 1970-01-01 00:00:00.000000000 +0000 +@@ -1,14 +0,0 @@ +-// Copyright 2021 The Go Authors. All rights reserved. +-// Use of this source code is governed by a BSD-style +-// license that can be found in the LICENSE file. +- +-//go:build !go1.20 +-// +build !go1.20 +- +-package settings +- +-import "context" +- +-const GofumptSupported = false +- +-var GofumptFormat func(ctx context.Context, langVersion, modulePath string, src []byte) ([]byte, error) +diff -urN a/gopls/internal/settings/gofumpt_120.go b/gopls/internal/settings/gofumpt_120.go +--- a/gopls/internal/settings/gofumpt_120.go 2000-01-01 00:00:00.000000000 -0000 ++++ b/gopls/internal/settings/gofumpt_120.go 1970-01-01 00:00:00.000000000 +0000 +@@ -1,80 +0,0 @@ +-// Copyright 2022 The Go Authors. All rights reserved. +-// Use of this source code is governed by a BSD-style +-// license that can be found in the LICENSE file. +- +-//go:build go1.20 +-// +build go1.20 +- +-package settings +- +-import ( +- "context" +- "fmt" +- +- "mvdan.cc/gofumpt/format" +-) +- +-const GofumptSupported = true +- +-// GofumptFormat allows the gopls module to wire in a call to +-// gofumpt/format.Source. langVersion and modulePath are used for some +-// Gofumpt formatting rules -- see the Gofumpt documentation for details. +-var GofumptFormat = func(ctx context.Context, langVersion, modulePath string, src []byte) ([]byte, error) { +- fixedVersion, err := fixLangVersion(langVersion) +- if err != nil { +- return nil, err +- } +- return format.Source(src, format.Options{ +- LangVersion: fixedVersion, +- ModulePath: modulePath, +- }) +-} +- +-// fixLangVersion function cleans the input so that gofumpt doesn't panic. It is +-// rather permissive, and accepts version strings that aren't technically valid +-// in a go.mod file. +-// +-// More specifically, it looks for an optional 'v' followed by 1-3 +-// '.'-separated numbers. The resulting string is stripped of any suffix beyond +-// this expected version number pattern. +-// +-// See also golang/go#61692: gofumpt does not accept the new language versions +-// appearing in go.mod files (e.g. go1.21rc3). +-func fixLangVersion(input string) (string, error) { +- bad := func() (string, error) { +- return "", fmt.Errorf("invalid language version syntax %q", input) +- } +- if input == "" { +- return input, nil +- } +- i := 0 +- if input[0] == 'v' { // be flexible about 'v' +- i++ +- } +- // takeDigits consumes ascii numerals 0-9 and reports if at least one was +- // consumed. +- takeDigits := func() bool { +- found := false +- for ; i < len(input) && '0' <= input[i] && input[i] <= '9'; i++ { +- found = true +- } +- return found +- } +- if !takeDigits() { // versions must start with at least one number +- return bad() +- } +- +- // Accept optional minor and patch versions. +- for n := 0; n < 2; n++ { +- if i < len(input) && input[i] == '.' { +- // Look for minor/patch version. +- i++ +- if !takeDigits() { +- i-- +- break +- } +- } +- } +- // Accept any suffix. +- return input[:i], nil +-} +diff -urN a/gopls/internal/settings/gofumpt_120_test.go b/gopls/internal/settings/gofumpt_120_test.go +--- a/gopls/internal/settings/gofumpt_120_test.go 2000-01-01 00:00:00.000000000 -0000 ++++ b/gopls/internal/settings/gofumpt_120_test.go 1970-01-01 00:00:00.000000000 +0000 +@@ -1,53 +0,0 @@ +-// Copyright 2022 The Go Authors. All rights reserved. +-// Use of this source code is governed by a BSD-style +-// license that can be found in the LICENSE file. +- +-//go:build go1.20 +-// +build go1.20 +- +-package settings +- +-import "testing" +- +-func TestFixLangVersion(t *testing.T) { +- tests := []struct { +- input, want string +- wantErr bool +- }{ +- {"", "", false}, +- {"1.18", "1.18", false}, +- {"v1.18", "v1.18", false}, +- {"1.21", "1.21", false}, +- {"1.21rc3", "1.21", false}, +- {"1.21.0", "1.21.0", false}, +- {"1.21.1", "1.21.1", false}, +- {"v1.21.1", "v1.21.1", false}, +- {"v1.21.0rc1", "v1.21.0", false}, // not technically valid, but we're flexible +- {"v1.21.0.0", "v1.21.0", false}, // also technically invalid +- {"1.1", "1.1", false}, +- {"v1", "v1", false}, +- {"1", "1", false}, +- {"v1.21.", "v1.21", false}, // also invalid +- {"1.21.", "1.21", false}, +- +- // Error cases. +- {"rc1", "", true}, +- {"x1.2.3", "", true}, +- } +- +- for _, test := range tests { +- got, err := fixLangVersion(test.input) +- if test.wantErr { +- if err == nil { +- t.Errorf("fixLangVersion(%q) succeeded unexpectedly", test.input) +- } +- continue +- } +- if err != nil { +- t.Fatalf("fixLangVersion(%q) failed: %v", test.input, err) +- } +- if got != test.want { +- t.Errorf("fixLangVersion(%q) = %s, want %s", test.input, got, test.want) +- } +- } +-} diff -urN a/gopls/internal/settings/json.go b/gopls/internal/settings/json.go --- a/gopls/internal/settings/json.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/settings/json.go 1970-01-01 00:00:00.000000000 +0000 @@ -95682,7 +97327,7 @@ diff -urN a/gopls/internal/settings/json.go b/gopls/internal/settings/json.go diff -urN a/gopls/internal/settings/settings.go b/gopls/internal/settings/settings.go --- a/gopls/internal/settings/settings.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/settings/settings.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,1503 +0,0 @@ +@@ -1,1259 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -95690,70 +97335,14 @@ diff -urN a/gopls/internal/settings/settings.go b/gopls/internal/settings/settin -package settings - -import ( -- "context" - "fmt" - "path/filepath" -- "regexp" - "runtime" - "strings" - "time" - -- "golang.org/x/tools/go/analysis" -- "golang.org/x/tools/go/analysis/passes/appends" -- "golang.org/x/tools/go/analysis/passes/asmdecl" -- "golang.org/x/tools/go/analysis/passes/assign" -- "golang.org/x/tools/go/analysis/passes/atomic" -- "golang.org/x/tools/go/analysis/passes/atomicalign" -- "golang.org/x/tools/go/analysis/passes/bools" -- "golang.org/x/tools/go/analysis/passes/buildtag" -- "golang.org/x/tools/go/analysis/passes/cgocall" -- "golang.org/x/tools/go/analysis/passes/composite" -- "golang.org/x/tools/go/analysis/passes/copylock" -- "golang.org/x/tools/go/analysis/passes/deepequalerrors" -- "golang.org/x/tools/go/analysis/passes/defers" -- "golang.org/x/tools/go/analysis/passes/directive" -- "golang.org/x/tools/go/analysis/passes/errorsas" -- "golang.org/x/tools/go/analysis/passes/fieldalignment" -- "golang.org/x/tools/go/analysis/passes/httpresponse" -- "golang.org/x/tools/go/analysis/passes/ifaceassert" -- "golang.org/x/tools/go/analysis/passes/loopclosure" -- "golang.org/x/tools/go/analysis/passes/lostcancel" -- "golang.org/x/tools/go/analysis/passes/nilfunc" -- "golang.org/x/tools/go/analysis/passes/nilness" -- "golang.org/x/tools/go/analysis/passes/printf" -- "golang.org/x/tools/go/analysis/passes/shadow" -- "golang.org/x/tools/go/analysis/passes/shift" -- "golang.org/x/tools/go/analysis/passes/slog" -- "golang.org/x/tools/go/analysis/passes/sortslice" -- "golang.org/x/tools/go/analysis/passes/stdmethods" -- "golang.org/x/tools/go/analysis/passes/stdversion" -- "golang.org/x/tools/go/analysis/passes/stringintconv" -- "golang.org/x/tools/go/analysis/passes/structtag" -- "golang.org/x/tools/go/analysis/passes/testinggoroutine" -- "golang.org/x/tools/go/analysis/passes/tests" -- "golang.org/x/tools/go/analysis/passes/timeformat" -- "golang.org/x/tools/go/analysis/passes/unmarshal" -- "golang.org/x/tools/go/analysis/passes/unreachable" -- "golang.org/x/tools/go/analysis/passes/unsafeptr" -- "golang.org/x/tools/go/analysis/passes/unusedresult" -- "golang.org/x/tools/go/analysis/passes/unusedwrite" -- "golang.org/x/tools/gopls/internal/analysis/deprecated" -- "golang.org/x/tools/gopls/internal/analysis/embeddirective" -- "golang.org/x/tools/gopls/internal/analysis/fillreturns" -- "golang.org/x/tools/gopls/internal/analysis/infertypeargs" -- "golang.org/x/tools/gopls/internal/analysis/nonewvars" -- "golang.org/x/tools/gopls/internal/analysis/noresultvalues" -- "golang.org/x/tools/gopls/internal/analysis/simplifycompositelit" -- "golang.org/x/tools/gopls/internal/analysis/simplifyrange" -- "golang.org/x/tools/gopls/internal/analysis/simplifyslice" -- "golang.org/x/tools/gopls/internal/analysis/stubmethods" -- "golang.org/x/tools/gopls/internal/analysis/undeclaredname" -- "golang.org/x/tools/gopls/internal/analysis/unusedparams" -- "golang.org/x/tools/gopls/internal/analysis/unusedvariable" -- "golang.org/x/tools/gopls/internal/analysis/useany" - "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/protocol" -- "golang.org/x/tools/gopls/internal/protocol/command" -) - -type Annotation string @@ -95774,32 +97363,19 @@ diff -urN a/gopls/internal/settings/settings.go b/gopls/internal/settings/settin - -// Options holds various configuration that affects Gopls execution, organized -// by the nature or origin of the settings. +-// +-// Options must be comparable with reflect.DeepEqual. -type Options struct { - ClientOptions - ServerOptions - UserOptions - InternalOptions -- Hooks --} -- --// IsAnalyzerEnabled reports whether an analyzer with the given name is --// enabled. --// --// TODO(rfindley): refactor to simplify this function. We no longer need the --// different categories of analyzer. --func (opts *Options) IsAnalyzerEnabled(name string) bool { -- for _, amap := range []map[string]*Analyzer{opts.DefaultAnalyzers, opts.StaticcheckAnalyzers} { -- for _, analyzer := range amap { -- if analyzer.Analyzer.Name == name && analyzer.IsEnabled(opts) { -- return true -- } -- } -- } -- return false -} - -// ClientOptions holds LSP-specific configuration that is provided by the -// client. +-// +-// ClientOptions must be comparable with reflect.DeepEqual. -type ClientOptions struct { - ClientInfo *protocol.ClientInfo - InsertTextFormat protocol.InsertTextFormat @@ -95822,11 +97398,14 @@ diff -urN a/gopls/internal/settings/settings.go b/gopls/internal/settings/settin - -// ServerOptions holds LSP-specific configuration that is provided by the -// server. +-// +-// ServerOptions must be comparable with reflect.DeepEqual. -type ServerOptions struct { - SupportedCodeActions map[file.Kind]map[protocol.CodeActionKind]bool - SupportedCommands []string -} - +-// Note: BuildOptions must be comparable with reflect.DeepEqual. -type BuildOptions struct { - // BuildFlags is the set of flags passed on to the build system when invoked. - // It is applied to queries like `go list`, which is used when discovering files. @@ -95874,10 +97453,6 @@ diff -urN a/gopls/internal/settings/settings.go b/gopls/internal/settings/settin - // gopls has to do to keep your workspace up to date. - ExpandWorkspaceToModule bool `status:"experimental"` - -- // AllowModfileModifications disables -mod=readonly, allowing imports from -- // out-of-scope modules. This option will eventually be removed. -- AllowModfileModifications bool `status:"experimental"` -- - // AllowImplicitNetworkAccess disables GOPROXY=off, allowing implicit module - // downloads rather than requiring user action. This option will eventually - // be removed. @@ -95904,6 +97479,7 @@ diff -urN a/gopls/internal/settings/settings.go b/gopls/internal/settings/settin - StandaloneTags []string -} - +-// Note: UIOptions must be comparable with reflect.DeepEqual. -type UIOptions struct { - DocumentationOptions - CompletionOptions @@ -95931,7 +97507,8 @@ diff -urN a/gopls/internal/settings/settings.go b/gopls/internal/settings/settin - Codelenses map[string]bool - - // SemanticTokens controls whether the LSP server will send -- // semantic tokens to the client. +- // semantic tokens to the client. If false, gopls will send empty semantic +- // tokens. - SemanticTokens bool `status:"experimental"` - - // NoSemanticString turns off the sending of the semantic token 'string' @@ -95941,6 +97518,7 @@ diff -urN a/gopls/internal/settings/settings.go b/gopls/internal/settings/settin - NoSemanticNumber bool `status:"experimental"` -} - +-// Note: CompletionOptions must be comparable with reflect.DeepEqual. -type CompletionOptions struct { - // Placeholders enables placeholders for function parameters or struct - // fields in completion responses. @@ -95969,6 +97547,7 @@ diff -urN a/gopls/internal/settings/settings.go b/gopls/internal/settings/settin - CompleteFunctionCalls bool -} - +-// Note: DocumentationOptions must be comparable with reflect.DeepEqual. -type DocumentationOptions struct { - // HoverKind controls the information that appears in the hover text. - // SingleLine and Structured are intended for use only by authors of editor plugins. @@ -95990,6 +97569,7 @@ diff -urN a/gopls/internal/settings/settings.go b/gopls/internal/settings/settin - LinksInHover bool -} - +-// Note: FormattingOptions must be comparable with reflect.DeepEqual. -type FormattingOptions struct { - // Local is the equivalent of the `goimports -local` flag, which puts - // imports beginning with this string after third-party packages. It should @@ -96001,6 +97581,7 @@ diff -urN a/gopls/internal/settings/settings.go b/gopls/internal/settings/settin - Gofumpt bool -} - +-// Note: DiagnosticOptions must be comparable with reflect.DeepEqual. -type DiagnosticOptions struct { - // Analyses specify analyses that the user would like to enable or disable. - // A map of the names of analysis passes that should be enabled/disabled. @@ -96083,15 +97664,16 @@ diff -urN a/gopls/internal/settings/settings.go b/gopls/internal/settings/settin - SymbolStyle SymbolStyle `status:"advanced"` - - // SymbolScope controls which packages are searched for workspace/symbol -- // requests. The default value, "workspace", searches only workspace -- // packages. The legacy behavior, "all", causes all loaded packages to be -- // searched, including dependencies; this is more expensive and may return -- // unwanted results. +- // requests. When the scope is "workspace", gopls searches only workspace +- // packages. When the scope is "all", gopls searches all loaded packages, +- // including dependencies and the standard library. - SymbolScope SymbolScope -} - -// UserOptions holds custom Gopls configuration (not part of the LSP) that is -// modified by the client. +-// +-// UserOptions must be comparable with reflect.DeepEqual. -type UserOptions struct { - BuildOptions - UIOptions @@ -96122,30 +97704,6 @@ diff -urN a/gopls/internal/settings/settings.go b/gopls/internal/settings/settin - } -} - --// Hooks contains configuration that is provided to the Gopls command by the --// main package. --type Hooks struct { -- // LicensesText holds third party licenses for software used by gopls. -- LicensesText string -- -- // Whether staticcheck is supported. -- StaticcheckSupported bool -- -- // URLRegexp is used to find potential URLs in comments/strings. -- // -- // Not all matches are shown to the user: if the matched URL is not detected -- // as valid, it will be skipped. -- URLRegexp *regexp.Regexp -- -- // GofumptFormat allows the gopls module to wire-in a call to -- // gofumpt/format.Source. langVersion and modulePath are used for some -- // Gofumpt formatting rules -- see the Gofumpt documentation for details. -- GofumptFormat func(ctx context.Context, langVersion, modulePath string, src []byte) ([]byte, error) -- -- DefaultAnalyzers map[string]*Analyzer -- StaticcheckAnalyzers map[string]*Analyzer --} -- -// InternalOptions contains settings that are not intended for use by the -// average user. These may be settings used by tests or outdated settings that -// will soon be deprecated. Some of these settings may not even be configurable @@ -96375,24 +97933,10 @@ diff -urN a/gopls/internal/settings/settings.go b/gopls/internal/settings/settin - switch opts := opts.(type) { - case nil: - case map[string]any: -- // If the user's settings contains "allExperiments", set that first, -- // and then let them override individual settings independently. -- var enableExperiments bool -- for name, value := range opts { -- if b, ok := value.(bool); name == "allExperiments" && ok && b { -- enableExperiments = true -- options.EnableAllExperiments() -- } -- } - seen := map[string]struct{}{} - for name, value := range opts { - results = append(results, options.set(name, value, seen)) - } -- // Finally, enable any experimental features that are specified in -- // maps, which allows users to individually toggle them on or off. -- if enableExperiments { -- options.enableAllExperimentMaps() -- } - default: - results = append(results, OptionResult{ - Value: opts, @@ -96458,16 +98002,10 @@ diff -urN a/gopls/internal/settings/settings.go b/gopls/internal/settings/settin - result := &Options{ - ClientOptions: o.ClientOptions, - InternalOptions: o.InternalOptions, -- Hooks: Hooks{ -- StaticcheckSupported: o.StaticcheckSupported, -- GofumptFormat: o.GofumptFormat, -- URLRegexp: o.URLRegexp, -- }, -- ServerOptions: o.ServerOptions, -- UserOptions: o.UserOptions, +- ServerOptions: o.ServerOptions, +- UserOptions: o.UserOptions, - } -- // Fully clone any slice or map fields. Only Hooks, ExperimentalOptions, -- // and UserOptions can be modified. +- // Fully clone any slice or map fields. Only UserOptions can be modified. - copyStringMap := func(src map[string]bool) map[string]bool { - dst := make(map[string]bool) - for k, v := range src { @@ -96488,45 +98026,9 @@ diff -urN a/gopls/internal/settings/settings.go b/gopls/internal/settings/settin - result.DirectoryFilters = copySlice(o.DirectoryFilters) - result.StandaloneTags = copySlice(o.StandaloneTags) - -- copyAnalyzerMap := func(src map[string]*Analyzer) map[string]*Analyzer { -- dst := make(map[string]*Analyzer) -- for k, v := range src { -- dst[k] = v -- } -- return dst -- } -- result.DefaultAnalyzers = copyAnalyzerMap(o.DefaultAnalyzers) -- result.StaticcheckAnalyzers = copyAnalyzerMap(o.StaticcheckAnalyzers) - return result -} - --func (o *Options) AddStaticcheckAnalyzer(a *analysis.Analyzer, enabled bool, severity protocol.DiagnosticSeverity) { -- o.StaticcheckAnalyzers[a.Name] = &Analyzer{ -- Analyzer: a, -- Enabled: enabled, -- Severity: severity, -- } --} -- --// EnableAllExperiments turns on all of the experimental "off-by-default" --// features offered by gopls. Any experimental features specified in maps --// should be enabled in enableAllExperimentMaps. --func (o *Options) EnableAllExperiments() { -- o.SemanticTokens = true --} -- --func (o *Options) enableAllExperimentMaps() { -- if _, ok := o.Codelenses[string(command.GCDetails)]; !ok { -- o.Codelenses[string(command.GCDetails)] = true -- } -- if _, ok := o.Codelenses[string(command.RunGovulncheck)]; !ok { -- o.Codelenses[string(command.RunGovulncheck)] = true -- } -- if _, ok := o.Analyses[unusedvariable.Analyzer.Name]; !ok { -- o.Analyses[unusedvariable.Analyzer.Name] = true -- } --} -- -// validateDirectoryFilter validates if the filter string -// - is not empty -// - start with either + or - @@ -96715,7 +98217,7 @@ diff -urN a/gopls/internal/settings/settings.go b/gopls/internal/settings/settin - case "staticcheck": - if v, ok := result.asBool(); ok { - o.Staticcheck = v -- if v && !o.StaticcheckSupported { +- if v && !StaticcheckSupported { - result.Error = fmt.Errorf("applying setting %q: staticcheck is not supported at %s;"+ - " rebuild gopls with a more recent version of Go", result.Name, runtime.Version()) - } @@ -96739,7 +98241,7 @@ diff -urN a/gopls/internal/settings/settings.go b/gopls/internal/settings/settin - case "gofumpt": - if v, ok := result.asBool(); ok { - o.Gofumpt = v -- if v && o.GofumptFormat == nil { +- if v && !GofumptSupported { - result.Error = fmt.Errorf("applying setting %q: gofumpt is not supported at %s;"+ - " rebuild gopls with a more recent version of Go", result.Name, runtime.Version()) - } @@ -96810,10 +98312,10 @@ diff -urN a/gopls/internal/settings/settings.go b/gopls/internal/settings/settin - result.deprecated("") - - case "allowModfileModifications": -- result.softErrorf("gopls setting \"allowModfileModifications\" is deprecated.\nPlease comment on https://go.dev/issue/65546 if this impacts your workflow.") -- result.setBool(&o.AllowModfileModifications) +- result.deprecated("") - - case "allowImplicitNetworkAccess": +- result.softErrorf("gopls setting \"allowImplicitNetworkAccess\" is deprecated.\nPlease comment on https://go.dev/issue/66861 if this impacts your workflow.") - result.setBool(&o.AllowImplicitNetworkAccess) - - case "experimentalUseInvalidMetadata": @@ -96823,8 +98325,12 @@ diff -urN a/gopls/internal/settings/settings.go b/gopls/internal/settings/settin - result.setStringSlice(&o.StandaloneTags) - - case "allExperiments": -- // This setting should be handled before all of the other options are -- // processed, so do nothing here. +- // golang/go#65548: this setting is a no-op, but we fail don't report it as +- // deprecated, since the nightly VS Code injects it. +- // +- // If, in the future, VS Code stops injecting this, we could theoretically +- // report an error here, but it also seems harmless to keep ignoring this +- // setting forever. - - case "newDiff": - result.deprecated("") @@ -97081,115 +98587,10 @@ diff -urN a/gopls/internal/settings/settings.go b/gopls/internal/settings/settin - *s = v - } -} -- --func analyzers() map[string]*Analyzer { -- return map[string]*Analyzer{ -- // The traditional vet suite: -- appends.Analyzer.Name: {Analyzer: appends.Analyzer, Enabled: true}, -- asmdecl.Analyzer.Name: {Analyzer: asmdecl.Analyzer, Enabled: true}, -- assign.Analyzer.Name: {Analyzer: assign.Analyzer, Enabled: true}, -- atomic.Analyzer.Name: {Analyzer: atomic.Analyzer, Enabled: true}, -- bools.Analyzer.Name: {Analyzer: bools.Analyzer, Enabled: true}, -- buildtag.Analyzer.Name: {Analyzer: buildtag.Analyzer, Enabled: true}, -- cgocall.Analyzer.Name: {Analyzer: cgocall.Analyzer, Enabled: true}, -- composite.Analyzer.Name: {Analyzer: composite.Analyzer, Enabled: true}, -- copylock.Analyzer.Name: {Analyzer: copylock.Analyzer, Enabled: true}, -- defers.Analyzer.Name: {Analyzer: defers.Analyzer, Enabled: true}, -- deprecated.Analyzer.Name: { -- Analyzer: deprecated.Analyzer, -- Enabled: true, -- Severity: protocol.SeverityHint, -- Tag: []protocol.DiagnosticTag{protocol.Deprecated}, -- }, -- directive.Analyzer.Name: {Analyzer: directive.Analyzer, Enabled: true}, -- errorsas.Analyzer.Name: {Analyzer: errorsas.Analyzer, Enabled: true}, -- httpresponse.Analyzer.Name: {Analyzer: httpresponse.Analyzer, Enabled: true}, -- ifaceassert.Analyzer.Name: {Analyzer: ifaceassert.Analyzer, Enabled: true}, -- loopclosure.Analyzer.Name: {Analyzer: loopclosure.Analyzer, Enabled: true}, -- lostcancel.Analyzer.Name: {Analyzer: lostcancel.Analyzer, Enabled: true}, -- nilfunc.Analyzer.Name: {Analyzer: nilfunc.Analyzer, Enabled: true}, -- printf.Analyzer.Name: {Analyzer: printf.Analyzer, Enabled: true}, -- shift.Analyzer.Name: {Analyzer: shift.Analyzer, Enabled: true}, -- slog.Analyzer.Name: {Analyzer: slog.Analyzer, Enabled: true}, -- stdmethods.Analyzer.Name: {Analyzer: stdmethods.Analyzer, Enabled: true}, -- stringintconv.Analyzer.Name: {Analyzer: stringintconv.Analyzer, Enabled: true}, -- structtag.Analyzer.Name: {Analyzer: structtag.Analyzer, Enabled: true}, -- tests.Analyzer.Name: {Analyzer: tests.Analyzer, Enabled: true}, -- unmarshal.Analyzer.Name: {Analyzer: unmarshal.Analyzer, Enabled: true}, -- unreachable.Analyzer.Name: {Analyzer: unreachable.Analyzer, Enabled: true}, -- unsafeptr.Analyzer.Name: {Analyzer: unsafeptr.Analyzer, Enabled: true}, -- unusedresult.Analyzer.Name: {Analyzer: unusedresult.Analyzer, Enabled: true}, -- -- // Non-vet analyzers: -- // - some (nilness, unusedwrite) use go/ssa; -- // - some (unusedwrite) report bad code but not always a bug, -- // so are not suitable for vet. -- atomicalign.Analyzer.Name: {Analyzer: atomicalign.Analyzer, Enabled: true}, -- deepequalerrors.Analyzer.Name: {Analyzer: deepequalerrors.Analyzer, Enabled: true}, -- fieldalignment.Analyzer.Name: {Analyzer: fieldalignment.Analyzer, Enabled: false}, -- nilness.Analyzer.Name: {Analyzer: nilness.Analyzer, Enabled: true}, -- shadow.Analyzer.Name: {Analyzer: shadow.Analyzer, Enabled: false}, -- sortslice.Analyzer.Name: {Analyzer: sortslice.Analyzer, Enabled: true}, -- testinggoroutine.Analyzer.Name: {Analyzer: testinggoroutine.Analyzer, Enabled: true}, -- unusedparams.Analyzer.Name: {Analyzer: unusedparams.Analyzer, Enabled: true}, -- unusedwrite.Analyzer.Name: {Analyzer: unusedwrite.Analyzer, Enabled: true}, -- useany.Analyzer.Name: {Analyzer: useany.Analyzer, Enabled: false}, -- infertypeargs.Analyzer.Name: { -- Analyzer: infertypeargs.Analyzer, -- Enabled: true, -- Severity: protocol.SeverityHint, -- }, -- timeformat.Analyzer.Name: {Analyzer: timeformat.Analyzer, Enabled: true}, -- embeddirective.Analyzer.Name: {Analyzer: embeddirective.Analyzer, Enabled: true}, -- -- // gofmt -s suite: -- simplifycompositelit.Analyzer.Name: { -- Analyzer: simplifycompositelit.Analyzer, -- Enabled: true, -- ActionKinds: []protocol.CodeActionKind{protocol.SourceFixAll, protocol.QuickFix}, -- }, -- simplifyrange.Analyzer.Name: { -- Analyzer: simplifyrange.Analyzer, -- Enabled: true, -- ActionKinds: []protocol.CodeActionKind{protocol.SourceFixAll, protocol.QuickFix}, -- }, -- simplifyslice.Analyzer.Name: { -- Analyzer: simplifyslice.Analyzer, -- Enabled: true, -- ActionKinds: []protocol.CodeActionKind{protocol.SourceFixAll, protocol.QuickFix}, -- }, -- stdversion.Analyzer.Name: { -- Analyzer: stdversion.Analyzer, -- Enabled: true, -- }, -- -- // Type error analyzers. -- // These analyzers enrich go/types errors with suggested fixes. -- fillreturns.Analyzer.Name: {Analyzer: fillreturns.Analyzer, Enabled: true}, -- nonewvars.Analyzer.Name: {Analyzer: nonewvars.Analyzer, Enabled: true}, -- noresultvalues.Analyzer.Name: {Analyzer: noresultvalues.Analyzer, Enabled: true}, -- stubmethods.Analyzer.Name: {Analyzer: stubmethods.Analyzer, Enabled: true}, -- undeclaredname.Analyzer.Name: {Analyzer: undeclaredname.Analyzer, Enabled: true}, -- // TODO(rfindley): why isn't the 'unusedvariable' analyzer enabled, if it -- // is only enhancing type errors with suggested fixes? -- // -- // In particular, enabling this analyzer could cause unused variables to be -- // greyed out, (due to the 'deletions only' fix). That seems like a nice UI -- // feature. -- unusedvariable.Analyzer.Name: {Analyzer: unusedvariable.Analyzer, Enabled: false}, -- } --} -- --func urlRegexp() *regexp.Regexp { -- // Ensure links are matched as full words, not anywhere. -- re := regexp.MustCompile(`\b(http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?\b`) -- re.Longest() -- return re --} diff -urN a/gopls/internal/settings/settings_test.go b/gopls/internal/settings/settings_test.go --- a/gopls/internal/settings/settings_test.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/settings/settings_test.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,206 +0,0 @@ +@@ -1,219 +0,0 @@ -// Copyright 2020 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -97197,17 +98598,27 @@ diff -urN a/gopls/internal/settings/settings_test.go b/gopls/internal/settings/s -package settings - -import ( +- "reflect" - "testing" - "time" -) - +-func TestDefaultsEquivalence(t *testing.T) { +- opts1 := DefaultOptions() +- opts2 := DefaultOptions() +- if !reflect.DeepEqual(opts1, opts2) { +- t.Fatal("default options are not equivalent using reflect.DeepEqual") +- } +-} +- -func TestSetOption(t *testing.T) { -- tests := []struct { +- type testCase struct { - name string - value interface{} - wantError bool - check func(Options) bool -- }{ +- } +- tests := []testCase{ - { - name: "symbolStyle", - value: "Dynamic", @@ -97236,12 +98647,6 @@ diff -urN a/gopls/internal/settings/settings_test.go b/gopls/internal/settings/s - check: func(o Options) bool { return o.CompletionBudget == 2*time.Second }, - }, - { -- name: "staticcheck", -- value: true, -- check: func(o Options) bool { return o.Staticcheck == true }, -- wantError: true, // o.StaticcheckSupported is unset -- }, -- { - name: "codelenses", - value: map[string]interface{}{"generate": true}, - check: func(o Options) bool { return o.Codelenses["generate"] }, @@ -97383,6 +98788,15 @@ diff -urN a/gopls/internal/settings/settings_test.go b/gopls/internal/settings/s - }, - } - +- if !StaticcheckSupported { +- tests = append(tests, testCase{ +- name: "staticcheck", +- value: true, +- check: func(o Options) bool { return o.Staticcheck == true }, +- wantError: true, // o.StaticcheckSupported is unset +- }) +- } +- - for _, test := range tests { - var opts Options - result := opts.set(test.name, test.value, map[string]struct{}{}) @@ -97399,7 +98813,7 @@ diff -urN a/gopls/internal/settings/settings_test.go b/gopls/internal/settings/s diff -urN a/gopls/internal/telemetry/cmd/stacks/stacks.go b/gopls/internal/telemetry/cmd/stacks/stacks.go --- a/gopls/internal/telemetry/cmd/stacks/stacks.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/telemetry/cmd/stacks/stacks.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,302 +0,0 @@ +@@ -1,335 +0,0 @@ -// Copyright 2023 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -97427,6 +98841,7 @@ diff -urN a/gopls/internal/telemetry/cmd/stacks/stacks.go b/gopls/internal/telem - - "golang.org/x/telemetry" - "golang.org/x/tools/gopls/internal/util/browser" +- "golang.org/x/tools/gopls/internal/util/maps" -) - -// flags @@ -97441,7 +98856,7 @@ diff -urN a/gopls/internal/telemetry/cmd/stacks/stacks.go b/gopls/internal/telem - - // Maps stack text to Version/GoVersion/GOOS/GOARCH string to counter. - stacks := make(map[string]map[string]int64) -- var total int +- var distinctStacks int - - // Maps stack to a telemetry URL. - stackToURL := make(map[string]string) @@ -97473,8 +98888,6 @@ diff -urN a/gopls/internal/telemetry/cmd/stacks/stacks.go b/gopls/internal/telem - } - for _, prog := range report.Programs { - if prog.Program == "golang.org/x/tools/gopls" && len(prog.Stacks) > 0 { -- total++ -- - // Include applicable client names (e.g. vscode, eglot). - var clients []string - var clientSuffix string @@ -97495,6 +98908,9 @@ diff -urN a/gopls/internal/telemetry/cmd/stacks/stacks.go b/gopls/internal/telem - if prog.Version == "devel" { - continue - } +- +- distinctStacks++ +- - info := fmt.Sprintf("%s@%s %s %s/%s%s", - prog.Program, prog.Version, - prog.GoVersion, prog.GOOS, prog.GOARCH, @@ -97520,6 +98936,8 @@ diff -urN a/gopls/internal/telemetry/cmd/stacks/stacks.go b/gopls/internal/telem - } - - // Query GitHub for existing GitHub issues. +- // (Note: there may be multiple Issue records +- // for the same logical issue, i.e. Issue.Number.) - issuesByStackID := make(map[string]*Issue) - for len(stackIDs) > 0 { - // For some reason GitHub returns 422 UnprocessableEntity @@ -97545,87 +98963,49 @@ diff -urN a/gopls/internal/telemetry/cmd/stacks/stacks.go b/gopls/internal/telem - } - } - -- fmt.Printf("Found %d stacks in last %v days:\n", total, *daysFlag) +- fmt.Printf("Found %d distinct stacks in last %v days:\n", distinctStacks, *daysFlag) - - // For each stack, show existing issue or create a new one. +- // Aggregate stack IDs by issue summary. +- var ( +- // Both vars map the summary line to the stack count. +- existingIssues = make(map[string]int64) +- newIssues = make(map[string]int64) +- ) - for stack, counts := range stacks { - id := stackID(stack) - -- // Existing issue? -- issue, ok := issuesByStackID[id] -- if ok { -- if issue != nil { -- fmt.Printf("#%d: %s [%s]\n", -- issue.Number, issue.Title, issue.State) -- } else { -- // We just created a "New issue" browser tab -- // for this stackID. -- issuesByStackID[id] = nil // suppress dups -- } -- continue -- } -- -- // Create new issue. -- issuesByStackID[id] = nil // suppress dups -- -- // Use a heuristic to find a suitable symbol to blame -- // in the title: the first public function or method -- // of a public type, in gopls, to appear in the stack -- // trace. We can always refine it later. -- var symbol string -- for _, line := range strings.Split(stack, "\n") { -- // Look for: -- // gopls/.../pkg.Func -- // gopls/.../pkg.Type.method -- // gopls/.../pkg.(*Type).method -- if strings.Contains(line, "internal/util/bug.") { -- continue // not interesting -- } -- if _, rest, ok := strings.Cut(line, "golang.org/x/tools/gopls/"); ok { -- if i := strings.IndexByte(rest, '.'); i >= 0 { -- rest = rest[i+1:] -- rest = strings.TrimPrefix(rest, "(*") -- if rest != "" && 'A' <= rest[0] && rest[0] <= 'Z' { -- rest, _, _ = strings.Cut(rest, ":") -- symbol = " " + rest -- break -- } -- } -- } +- var total int64 +- for _, count := range counts { +- total += count - } - -- // Populate the form (title, body, label) -- title := fmt.Sprintf("x/tools/gopls:%s bug reported by telemetry", symbol) -- body := new(bytes.Buffer) -- fmt.Fprintf(body, "This stack `%s` was [reported by telemetry](%s):\n\n", -- id, stackToURL[stack]) -- fmt.Fprintf(body, "```\n%s\n```\n", stack) -- -- // Add counts, gopls version, and platform info. -- // This isn't very precise but should provide clues. -- // -- // TODO(adonovan): link each stack (ideally each frame) to source: -- // https://cs.opensource.google/go/x/tools/+/gopls/VERSION:gopls/FILE;l=LINE -- // (Requires parsing stack, shallow-cloning gopls module at that tag, and -- // computing correct line offsets. Would be labor-saving though.) -- fmt.Fprintf(body, "```\n") -- for info, count := range counts { -- fmt.Fprintf(body, "%s (%d)\n", info, count) +- if issue, ok := issuesByStackID[id]; ok { +- // existing issue +- summary := fmt.Sprintf("#%d: %s [%s]", +- issue.Number, issue.Title, issue.State) +- existingIssues[summary] += total +- } else { +- // new issue +- title := newIssue(stack, id, stackToURL[stack], counts) +- summary := fmt.Sprintf("%s: %s [%s]", id, title, "new") +- newIssues[summary] += total - } -- fmt.Fprintf(body, "```\n\n") -- -- fmt.Fprintf(body, "Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.\n") -- -- const labels = "gopls,Tools,gopls/telemetry-wins,NeedsInvestigation" -- -- // Report it. -- if !browser.Open("https://github.com/golang/go/issues/new?labels=" + labels + "&title=" + url.QueryEscape(title) + "&body=" + url.QueryEscape(body.String())) { -- log.Print("Please file a new issue at golang.org/issue/new using this template:\n\n") -- log.Printf("Title: %s\n", title) -- log.Printf("Labels: %s\n", labels) -- log.Printf("Body: %s\n", body) +- } +- print := func(caption string, issues map[string]int64) { +- // Print items in descending frequency. +- keys := maps.Keys(issues) +- sort.Slice(keys, func(i, j int) bool { +- return issues[keys[i]] > issues[keys[j]] +- }) +- fmt.Printf("%s issues:\n", caption) +- for _, summary := range keys { +- count := issues[summary] +- fmt.Printf("%s (n=%d)\n", summary, count) - } - } +- print("Existing", existingIssues) +- print("New", newIssues) -} - -// stackID returns a 32-bit identifier for a stack @@ -97647,6 +99027,73 @@ diff -urN a/gopls/internal/telemetry/cmd/stacks/stacks.go b/gopls/internal/telem - return base64.URLEncoding.EncodeToString(h.Sum(nil))[:6] -} - +-// newIssue creates a browser tab with a populated GitHub "New issue" +-// form for the specified stack. (The triage person is expected to +-// manually de-dup the issue before deciding whether to submit the form.) +-// +-// It returns the title. +-func newIssue(stack, id, jsonURL string, counts map[string]int64) string { +- // Use a heuristic to find a suitable symbol to blame +- // in the title: the first public function or method +- // of a public type, in gopls, to appear in the stack +- // trace. We can always refine it later. +- var symbol string +- for _, line := range strings.Split(stack, "\n") { +- // Look for: +- // gopls/.../pkg.Func +- // gopls/.../pkg.Type.method +- // gopls/.../pkg.(*Type).method +- if strings.Contains(line, "internal/util/bug.") { +- continue // not interesting +- } +- if _, rest, ok := strings.Cut(line, "golang.org/x/tools/gopls/"); ok { +- if i := strings.IndexByte(rest, '.'); i >= 0 { +- rest = rest[i+1:] +- rest = strings.TrimPrefix(rest, "(*") +- if rest != "" && 'A' <= rest[0] && rest[0] <= 'Z' { +- rest, _, _ = strings.Cut(rest, ":") +- symbol = " " + rest +- break +- } +- } +- } +- } +- +- // Populate the form (title, body, label) +- title := fmt.Sprintf("x/tools/gopls:%s bug reported by telemetry", symbol) +- body := new(bytes.Buffer) +- fmt.Fprintf(body, "This stack `%s` was [reported by telemetry](%s):\n\n", +- id, jsonURL) +- fmt.Fprintf(body, "```\n%s\n```\n", stack) +- +- // Add counts, gopls version, and platform info. +- // This isn't very precise but should provide clues. +- // +- // TODO(adonovan): link each stack (ideally each frame) to source: +- // https://cs.opensource.google/go/x/tools/+/gopls/VERSION:gopls/FILE;l=LINE +- // (Requires parsing stack, shallow-cloning gopls module at that tag, and +- // computing correct line offsets. Would be labor-saving though.) +- fmt.Fprintf(body, "```\n") +- for info, count := range counts { +- fmt.Fprintf(body, "%s (%d)\n", info, count) +- } +- fmt.Fprintf(body, "```\n\n") +- +- fmt.Fprintf(body, "Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.\n") +- +- const labels = "gopls,Tools,gopls/telemetry-wins,NeedsInvestigation" +- +- // Report it. +- if !browser.Open("https://github.com/golang/go/issues/new?labels=" + labels + "&title=" + url.QueryEscape(title) + "&body=" + url.QueryEscape(body.String())) { +- log.Print("Please file a new issue at golang.org/issue/new using this template:\n\n") +- log.Printf("Title: %s\n", title) +- log.Printf("Labels: %s\n", labels) +- log.Printf("Body: %s\n", body) +- } +- +- return title +-} +- -// -- GitHub search -- - -// searchIssues queries the GitHub issue tracker. @@ -97832,7 +99279,6 @@ diff -urN a/gopls/internal/telemetry/telemetry_test.go b/gopls/internal/telemetr - - "golang.org/x/telemetry/counter" - "golang.org/x/telemetry/counter/countertest" // requires go1.21+ -- "golang.org/x/tools/gopls/internal/hooks" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/protocol/command" - "golang.org/x/tools/gopls/internal/telemetry" @@ -97846,8 +99292,9 @@ diff -urN a/gopls/internal/telemetry/telemetry_test.go b/gopls/internal/telemetr - panic(err) - } - countertest.Open(tmp) -- defer os.RemoveAll(tmp) -- Main(m, hooks.Options) +- code := Main(m) +- os.RemoveAll(tmp) +- os.Exit(code) -} - -func TestTelemetry(t *testing.T) { @@ -99798,7 +101245,7 @@ diff -urN a/gopls/internal/test/compare/text_test.go b/gopls/internal/test/compa diff -urN a/gopls/internal/test/integration/bench/bench_test.go b/gopls/internal/test/integration/bench/bench_test.go --- a/gopls/internal/test/integration/bench/bench_test.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/test/integration/bench/bench_test.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,351 +0,0 @@ +@@ -1,350 +0,0 @@ -// Copyright 2020 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -99822,7 +101269,6 @@ diff -urN a/gopls/internal/test/integration/bench/bench_test.go b/gopls/internal - "time" - - "golang.org/x/tools/gopls/internal/cmd" -- "golang.org/x/tools/gopls/internal/hooks" - "golang.org/x/tools/gopls/internal/protocol/command" - "golang.org/x/tools/gopls/internal/test/integration" - "golang.org/x/tools/gopls/internal/test/integration/fake" @@ -99858,7 +101304,7 @@ diff -urN a/gopls/internal/test/integration/bench/bench_test.go b/gopls/internal -func TestMain(m *testing.M) { - bug.PanicOnBugs = true - if os.Getenv(runAsGopls) == "true" { -- tool.Main(context.Background(), cmd.New(hooks.Options), os.Args[1:]) +- tool.Main(context.Background(), cmd.New(), os.Args[1:]) - os.Exit(0) - } - event.SetExporter(nil) // don't log to stderr @@ -101270,7 +102716,7 @@ diff -urN a/gopls/internal/test/integration/bench/repo_test.go b/gopls/internal/ - inDir *string // if set, use this dir as url@commit, and don't delete - - dirOnce sync.Once -- dir string // directory contaning source code checked out to url@commit +- dir string // directory containing source code checked out to url@commit - - // shared editor state - editorOnce sync.Once @@ -101426,7 +102872,7 @@ diff -urN a/gopls/internal/test/integration/bench/repo_test.go b/gopls/internal/ diff -urN a/gopls/internal/test/integration/bench/stress_test.go b/gopls/internal/test/integration/bench/stress_test.go --- a/gopls/internal/test/integration/bench/stress_test.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/test/integration/bench/stress_test.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,94 +0,0 @@ +@@ -1,93 +0,0 @@ -// Copyright 2020 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -101441,7 +102887,6 @@ diff -urN a/gopls/internal/test/integration/bench/stress_test.go b/gopls/interna - "time" - - "golang.org/x/tools/gopls/internal/cache" -- "golang.org/x/tools/gopls/internal/hooks" - "golang.org/x/tools/gopls/internal/lsprpc" - "golang.org/x/tools/gopls/internal/test/integration/fake" - "golang.org/x/tools/internal/jsonrpc2" @@ -101474,7 +102919,7 @@ diff -urN a/gopls/internal/test/integration/bench/stress_test.go b/gopls/interna - t.Fatal(err) - } - -- server := lsprpc.NewStreamServer(cache.New(nil), false, hooks.Options) +- server := lsprpc.NewStreamServer(cache.New(nil), false, nil) - ts := servertest.NewPipeServer(server, jsonrpc2.NewRawStream) - ctx := context.Background() - @@ -101645,9 +103090,9 @@ diff -urN a/gopls/internal/test/integration/codelens/codelens_test.go b/gopls/in - -import ( - "fmt" +- "os" - "testing" - -- "golang.org/x/tools/gopls/internal/hooks" - "golang.org/x/tools/gopls/internal/server" - "golang.org/x/tools/gopls/internal/test/compare" - . "golang.org/x/tools/gopls/internal/test/integration" @@ -101660,7 +103105,7 @@ diff -urN a/gopls/internal/test/integration/codelens/codelens_test.go b/gopls/in - -func TestMain(m *testing.M) { - bug.PanicOnBugs = true -- Main(m, hooks.Options) +- os.Exit(Main(m)) -} - -func TestDisablingCodeLens(t *testing.T) { @@ -102312,6 +103757,7 @@ diff -urN a/gopls/internal/test/integration/completion/completion_test.go b/gopl - -import ( - "fmt" +- "os" - "sort" - "strings" - "testing" @@ -102320,7 +103766,6 @@ diff -urN a/gopls/internal/test/integration/completion/completion_test.go b/gopl - "github.com/google/go-cmp/cmp" - "golang.org/x/telemetry/counter" - "golang.org/x/telemetry/counter/countertest" -- "golang.org/x/tools/gopls/internal/hooks" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/server" - . "golang.org/x/tools/gopls/internal/test/integration" @@ -102331,7 +103776,7 @@ diff -urN a/gopls/internal/test/integration/completion/completion_test.go b/gopl - -func TestMain(m *testing.M) { - bug.PanicOnBugs = true -- Main(m, hooks.Options) +- os.Exit(Main(m)) -} - -const proxy = ` @@ -104150,10 +105595,10 @@ diff -urN a/gopls/internal/test/integration/debug/debug_test.go b/gopls/internal - "encoding/json" - "io" - "net/http" +- "os" - "strings" - "testing" - -- "golang.org/x/tools/gopls/internal/hooks" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/protocol/command" - . "golang.org/x/tools/gopls/internal/test/integration" @@ -104161,7 +105606,7 @@ diff -urN a/gopls/internal/test/integration/debug/debug_test.go b/gopls/internal -) - -func TestMain(m *testing.M) { -- Main(m, hooks.Options) +- os.Exit(Main(m)) -} - -func TestBugNotification(t *testing.T) { @@ -104181,7 +105626,7 @@ diff -urN a/gopls/internal/test/integration/debug/debug_test.go b/gopls/internal -// start the internal web server. -func TestStartDebugging(t *testing.T) { - WithOptions( -- Modes(Default|Experimental), // doesn't work in Forwarded mode +- Modes(Default), // doesn't work in Forwarded mode - ).Run(t, "", func(t *testing.T, env *Env) { - // Start a debugging server. - res, err := startDebugging(env.Ctx, env.Editor.Server, &command.DebuggingArgs{ @@ -104413,7 +105858,7 @@ diff -urN a/gopls/internal/test/integration/diagnostics/builtin_test.go b/gopls/ diff -urN a/gopls/internal/test/integration/diagnostics/diagnostics_test.go b/gopls/internal/test/integration/diagnostics/diagnostics_test.go --- a/gopls/internal/test/integration/diagnostics/diagnostics_test.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/test/integration/diagnostics/diagnostics_test.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,2226 +0,0 @@ +@@ -1,2195 +0,0 @@ -// Copyright 2020 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -104423,22 +105868,21 @@ diff -urN a/gopls/internal/test/integration/diagnostics/diagnostics_test.go b/go -import ( - "context" - "fmt" +- "os" - "os/exec" - "testing" - -- "golang.org/x/tools/gopls/internal/hooks" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/server" - . "golang.org/x/tools/gopls/internal/test/integration" - "golang.org/x/tools/gopls/internal/test/integration/fake" - "golang.org/x/tools/gopls/internal/util/bug" -- "golang.org/x/tools/gopls/internal/util/goversion" - "golang.org/x/tools/internal/testenv" -) - -func TestMain(m *testing.M) { - bug.PanicOnBugs = true -- Main(m, hooks.Options) +- os.Exit(Main(m)) -} - -// Use mod.com for all go.mod files due to golang/go#35230. @@ -105801,36 +107245,6 @@ diff -urN a/gopls/internal/test/integration/diagnostics/diagnostics_test.go b/go - }) -} - --func TestEnableAllExperiments(t *testing.T) { -- // Before the oldest supported Go version, gopls sends a warning to upgrade -- // Go, which fails the expectation below. -- testenv.NeedsGo1Point(t, goversion.OldestSupported()) -- -- const mod = ` ---- go.mod -- --module mod.com -- --go 1.12 ---- main.go -- --package main -- --import "bytes" -- --func b(c bytes.Buffer) { -- _ = 1 --} --` -- WithOptions( -- Settings{"allExperiments": true}, -- ).Run(t, mod, func(t *testing.T, env *Env) { -- // Confirm that the setting doesn't cause any warnings. -- env.OnceMet( -- InitialWorkspaceLoad, -- NoShownMessage(""), // empty substring to match any message -- ) -- }) --} -- -func TestSwig(t *testing.T) { - if _, err := exec.LookPath("swig"); err != nil { - t.Skip("skipping test: swig not available") @@ -106941,7 +108355,7 @@ diff -urN a/gopls/internal/test/integration/doc.go b/gopls/internal/test/integra -// ) -// -// func TestMain(m *testing.M) { --// Main(m, hooks.Options) +-// os.Exit(Main(m, hooks.Options)) -// } -// -// # Writing a simple integration test @@ -110986,7 +112400,7 @@ diff -urN a/gopls/internal/test/integration/fake/proxy.go b/gopls/internal/test/ diff -urN a/gopls/internal/test/integration/fake/sandbox.go b/gopls/internal/test/integration/fake/sandbox.go --- a/gopls/internal/test/integration/fake/sandbox.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/test/integration/fake/sandbox.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,299 +0,0 @@ +@@ -1,301 +0,0 @@ -// Copyright 2020 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -111278,7 +112692,9 @@ diff -urN a/gopls/internal/test/integration/fake/sandbox.go b/gopls/internal/tes -func (sb *Sandbox) Close() error { - var goCleanErr error - if sb.gopath != "" { -- goCleanErr = sb.RunGoCommand(context.Background(), "", "clean", []string{"-modcache"}, nil, false) +- // Important: run this command in RootDir so that it doesn't interact with +- // any toolchain downloads that may occur +- goCleanErr = sb.RunGoCommand(context.Background(), sb.RootDir(), "clean", []string{"-modcache"}, nil, false) - } - err := robustio.RemoveAll(sb.rootdir) - if err != nil || goCleanErr != nil { @@ -111972,17 +113388,17 @@ diff -urN a/gopls/internal/test/integration/inlayhints/inlayhints_test.go b/gopl -package inlayhint - -import ( +- "os" - "testing" - - "golang.org/x/tools/gopls/internal/golang" -- "golang.org/x/tools/gopls/internal/hooks" - . "golang.org/x/tools/gopls/internal/test/integration" - "golang.org/x/tools/gopls/internal/util/bug" -) - -func TestMain(m *testing.M) { - bug.PanicOnBugs = true -- Main(m, hooks.Options) +- os.Exit(Main(m)) -} - -func TestEnablingInlayHints(t *testing.T) { @@ -112075,10 +113491,79 @@ diff -urN a/gopls/internal/test/integration/misc/call_hierarchy_test.go b/gopls/ - env.Editor.Server.PrepareCallHierarchy(env.Ctx, ¶ms) - }) -} +diff -urN a/gopls/internal/test/integration/misc/codeactions_test.go b/gopls/internal/test/integration/misc/codeactions_test.go +--- a/gopls/internal/test/integration/misc/codeactions_test.go 2000-01-01 00:00:00.000000000 -0000 ++++ b/gopls/internal/test/integration/misc/codeactions_test.go 1970-01-01 00:00:00.000000000 +0000 +@@ -1,65 +0,0 @@ +-// Copyright 2024 The Go Authors. All rights reserved. +-// Use of this source code is governed by a BSD-style +-// license that can be found in the LICENSE file. +- +-package misc +- +-import ( +- "testing" +- +- "github.com/google/go-cmp/cmp" +- "golang.org/x/tools/gopls/internal/protocol" +- . "golang.org/x/tools/gopls/internal/test/integration" +-) +- +-// This test exercises the filtering of code actions in generated files. +-// Most code actions, being potential edits, are discarded, but +-// some (GoTest, GoDoc) are pure queries, and so are allowed. +-func TestCodeActionsInGeneratedFiles(t *testing.T) { +- const src = ` +--- go.mod -- +-module example.com +-go 1.19 +- +--- src.go -- +-package a +- +-func f() { g() } +-func g() {} +--- gen.go -- +-// Code generated by hand; DO NOT EDIT. +-package a +- +-func f() { g() } +-func g() {} +-` +- +- Run(t, src, func(t *testing.T, env *Env) { +- check := func(filename string, wantKind ...protocol.CodeActionKind) { +- env.OpenFile(filename) +- loc := env.RegexpSearch(filename, `g\(\)`) +- actions, err := env.Editor.CodeAction(env.Ctx, loc, nil) +- if err != nil { +- t.Fatal(err) +- } +- +- type kinds = map[protocol.CodeActionKind]bool +- got := make(kinds) +- for _, act := range actions { +- got[act.Kind] = true +- } +- want := make(kinds) +- for _, kind := range wantKind { +- want[kind] = true +- } +- +- if diff := cmp.Diff(want, got); diff != "" { +- t.Errorf("%s: unexpected CodeActionKinds: (-want +got):\n%s", +- filename, diff) +- t.Log(actions) +- } +- } +- check("src.go", protocol.GoDoc, protocol.RefactorExtract, protocol.RefactorInline) +- check("gen.go", protocol.GoDoc) // just "View package documentation" +- }) +-} diff -urN a/gopls/internal/test/integration/misc/configuration_test.go b/gopls/internal/test/integration/misc/configuration_test.go --- a/gopls/internal/test/integration/misc/configuration_test.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/test/integration/misc/configuration_test.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,186 +0,0 @@ +@@ -1,255 +0,0 @@ -// Copyright 2020 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -112120,7 +113605,7 @@ diff -urN a/gopls/internal/test/integration/misc/configuration_test.go b/gopls/i - NoDiagnostics(ForFile("a/a.go")), - ) - cfg := env.Editor.Config() -- cfg.Settings = map[string]interface{}{ +- cfg.Settings = map[string]any{ - "staticcheck": true, - } - env.ChangeConfiguration(cfg) @@ -112130,6 +113615,73 @@ diff -urN a/gopls/internal/test/integration/misc/configuration_test.go b/gopls/i - }) -} - +-func TestIdenticalConfiguration(t *testing.T) { +- // This test checks that changing configuration does not cause views to be +- // recreated if there is no configuration change. +- const files = ` +--- a.go -- +-package p +- +-func _() { +- var x *int +- y := *x +- _ = y +-} +-` +- Run(t, files, func(t *testing.T, env *Env) { +- // Sanity check: before disabling the nilness analyzer, we should have a +- // diagnostic for the nil dereference. +- env.OpenFile("a.go") +- env.AfterChange( +- Diagnostics( +- ForFile("a.go"), +- WithMessage("nil dereference"), +- ), +- ) +- +- // Collect the view ID before changing configuration. +- viewID := func() string { +- t.Helper() +- views := env.Views() +- if len(views) != 1 { +- t.Fatalf("got %d views, want 1", len(views)) +- } +- return views[0].ID +- } +- before := viewID() +- +- // Now disable the nilness analyzer. +- cfg := env.Editor.Config() +- cfg.Settings = map[string]any{ +- "analyses": map[string]any{ +- "nilness": false, +- }, +- } +- +- // This should cause the diagnostic to disappear... +- env.ChangeConfiguration(cfg) +- env.AfterChange( +- NoDiagnostics(), +- ) +- // ...and we should be on the second view. +- after := viewID() +- if after == before { +- t.Errorf("after configuration change, got view %q (same as before), want new view", after) +- } +- +- // Now change configuration again, this time with the same configuration as +- // before. We should still have no diagnostics... +- env.ChangeConfiguration(cfg) +- env.AfterChange( +- NoDiagnostics(), +- ) +- // ...and we should still be on the second view. +- if got := viewID(); got != after { +- t.Errorf("after second configuration change, got view %q, want %q", got, after) +- } +- }) +-} +- -// Test that clients can configure per-workspace configuration, which is -// queried via the scopeURI of a workspace/configuration request. -// (this was broken in golang/go#65519). @@ -112253,6 +113805,7 @@ diff -urN a/gopls/internal/test/integration/misc/configuration_test.go b/gopls/i - "experimentalWorkspaceModule": true, - "tempModfile": true, - "allowModfileModifications": true, +- "allowImplicitNetworkAccess": true, - }, - ).Run(t, "", func(t *testing.T, env *Env) { - env.OnceMet( @@ -112262,6 +113815,7 @@ diff -urN a/gopls/internal/test/integration/misc/configuration_test.go b/gopls/i - ShownMessage("experimentalWatchedFileDelay"), - ShownMessage("tempModfile"), - ShownMessage("allowModfileModifications"), +- ShownMessage("allowImplicitNetworkAccess"), - ) - }) -} @@ -114469,7 +116023,7 @@ diff -urN a/gopls/internal/test/integration/misc/hover_test.go b/gopls/internal/ diff -urN a/gopls/internal/test/integration/misc/imports_test.go b/gopls/internal/test/integration/misc/imports_test.go --- a/gopls/internal/test/integration/misc/imports_test.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/test/integration/misc/imports_test.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,293 +0,0 @@ +@@ -1,338 +0,0 @@ -// Copyright 2020 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -114544,7 +116098,7 @@ diff -urN a/gopls/internal/test/integration/misc/imports_test.go b/gopls/interna - Run(t, stuff, func(t *testing.T, env *Env) { - env.OpenFile("a.go") - was := env.BufferText("a.go") -- env.Await(NoDiagnostics()) +- env.AfterChange(NoDiagnostics()) - env.OrganizeImports("a.go") - is := env.BufferText("a.go") - if diff := compare.Text(was, is); diff != "" { @@ -114553,6 +116107,51 @@ diff -urN a/gopls/internal/test/integration/misc/imports_test.go b/gopls/interna - }) -} - +-func TestIssue66407(t *testing.T) { +- const files = ` +--- go.mod -- +-module foo +-go 1.21 +--- a.go -- +-package foo +- +-func f(x float64) float64 { +- return x + rand.Float64() +-} +--- b.go -- +-package foo +- +-func g() { +- _ = rand.Int63() +-} +-` +- WithOptions(Modes(Default)). +- Run(t, files, func(t *testing.T, env *Env) { +- env.OpenFile("a.go") +- was := env.BufferText("a.go") +- env.OrganizeImports("a.go") +- is := env.BufferText("a.go") +- // expect complaint that module is before 1.22 +- env.AfterChange(Diagnostics(ForFile("a.go"))) +- diff := compare.Text(was, is) +- // check that it found the 'right' rand +- if !strings.Contains(diff, `import "math/rand/v2"`) { +- t.Errorf("expected rand/v2, got %q", diff) +- } +- env.OpenFile("b.go") +- was = env.BufferText("b.go") +- env.OrganizeImports("b.go") +- // a.go still has its module problem but b.go is fine +- env.AfterChange(Diagnostics(ForFile("a.go")), +- NoDiagnostics(ForFile("b.go"))) +- is = env.BufferText("b.go") +- diff = compare.Text(was, is) +- if !strings.Contains(diff, `import "math/rand"`) { +- t.Errorf("expected math/rand, got %q", diff) +- } +- }) +-} +- -func TestVim1(t *testing.T) { - const vim1 = `package main - @@ -115009,10 +116608,10 @@ diff -urN a/gopls/internal/test/integration/misc/misc_test.go b/gopls/internal/t -package misc - -import ( +- "os" - "strings" - "testing" - -- "golang.org/x/tools/gopls/internal/hooks" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/test/integration" - . "golang.org/x/tools/gopls/internal/test/integration" @@ -115021,7 +116620,7 @@ diff -urN a/gopls/internal/test/integration/misc/misc_test.go b/gopls/internal/t - -func TestMain(m *testing.M) { - bug.PanicOnBugs = true -- integration.Main(m, hooks.Options) +- os.Exit(integration.Main(m)) -} - -// TestDocumentURIFix ensures that a DocumentURI supplied by the @@ -116857,7 +118456,7 @@ diff -urN a/gopls/internal/test/integration/misc/rename_test.go b/gopls/internal diff -urN a/gopls/internal/test/integration/misc/semantictokens_test.go b/gopls/internal/test/integration/misc/semantictokens_test.go --- a/gopls/internal/test/integration/misc/semantictokens_test.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/test/integration/misc/semantictokens_test.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,239 +0,0 @@ +@@ -1,234 +0,0 @@ -// Copyright 2021 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -116890,7 +118489,6 @@ diff -urN a/gopls/internal/test/integration/misc/semantictokens_test.go b/gopls/ -` - WithOptions( - Modes(Default), -- Settings{"allExperiments": true}, - ).Run(t, src, func(t *testing.T, env *Env) { - params := &protocol.SemanticTokensParams{} - const badURI = "http://foo" @@ -116951,7 +118549,6 @@ diff -urN a/gopls/internal/test/integration/misc/semantictokens_test.go b/gopls/ -` - WithOptions( - Modes(Default), -- Settings{"semanticTokens": true}, - ).Run(t, src, func(t *testing.T, env *Env) { - env.OpenFile("main.go") - env.AfterChange( @@ -116988,7 +118585,6 @@ diff -urN a/gopls/internal/test/integration/misc/semantictokens_test.go b/gopls/ -` - WithOptions( - Modes(Default), -- Settings{"semanticTokens": true}, - ).Run(t, src, func(t *testing.T, env *Env) { - env.OpenFile("main.go") - seen := env.SemanticTokensFull("main.go") @@ -117044,7 +118640,6 @@ diff -urN a/gopls/internal/test/integration/misc/semantictokens_test.go b/gopls/ - - WithOptions( - Modes(Default), -- Settings{"semanticTokens": true}, - ).Run(t, src, func(t *testing.T, env *Env) { - env.OpenFile("main.go") - seen := env.SemanticTokensFull("main.go") @@ -117059,7 +118654,7 @@ diff -urN a/gopls/internal/test/integration/misc/semantictokens_test.go b/gopls/ - src := ` --- go.mod -- -module example.com -- +- -go 1.21 --- main.go -- -package main @@ -117088,7 +118683,6 @@ diff -urN a/gopls/internal/test/integration/misc/semantictokens_test.go b/gopls/ - } - WithOptions( - Modes(Default), -- Settings{"semanticTokens": true}, - ).Run(t, src, func(t *testing.T, env *Env) { - env.OpenFile("main.go") - seen := env.SemanticTokensFull("main.go") @@ -117285,7 +118879,7 @@ diff -urN a/gopls/internal/test/integration/misc/signature_help_test.go b/gopls/ diff -urN a/gopls/internal/test/integration/misc/staticcheck_test.go b/gopls/internal/test/integration/misc/staticcheck_test.go --- a/gopls/internal/test/integration/misc/staticcheck_test.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/test/integration/misc/staticcheck_test.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,123 +0,0 @@ +@@ -1,124 +0,0 @@ -// Copyright 2022 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -117293,10 +118887,9 @@ diff -urN a/gopls/internal/test/integration/misc/staticcheck_test.go b/gopls/int -package misc - -import ( -- "os" -- "strings" - "testing" - +- "golang.org/x/tools/internal/aliases" - "golang.org/x/tools/internal/testenv" - - . "golang.org/x/tools/gopls/internal/test/integration" @@ -117305,9 +118898,10 @@ diff -urN a/gopls/internal/test/integration/misc/staticcheck_test.go b/gopls/int -func TestStaticcheckGenerics(t *testing.T) { - testenv.NeedsGo1Point(t, 20) // staticcheck requires go1.20+ - -- // TODO(golang/go#65249): re-enable and fix this test with gotypesalias=1. -- if strings.Contains(os.Getenv("GODEBUG"), "gotypesalias=1") { -- t.Skipf("staticcheck needs updates for materialized aliases") +- // TODO(golang/go#65249): re-enable and fix this test once we +- // update go.mod to go1.23 so that gotypesalias=1 becomes the default. +- if aliases.Enabled() { +- t.Skip("staticheck doesn't yet support aliases (dominikh/go-tools#1523)") - } - - const files = ` @@ -117375,9 +118969,10 @@ diff -urN a/gopls/internal/test/integration/misc/staticcheck_test.go b/gopls/int -func TestStaticcheckRelatedInfo(t *testing.T) { - testenv.NeedsGo1Point(t, 20) // staticcheck is only supported at Go 1.20+ - -- // TODO(golang/go#65249): re-enable and fix this test with gotypesalias=1. -- if strings.Contains(os.Getenv("GODEBUG"), "gotypesalias=1") { -- t.Skipf("staticcheck needs updates for materialized aliases") +- // TODO(golang/go#65249): re-enable and fix this test once we +- // update go.mod to go1.23 so that gotypesalias=1 becomes the default. +- if aliases.Enabled() { +- t.Skip("staticheck doesn't yet support aliases (dominikh/go-tools#1523)") - } - - const files = ` @@ -118468,7 +120063,7 @@ diff -urN a/gopls/internal/test/integration/misc/vuln_test.go b/gopls/internal/t diff -urN a/gopls/internal/test/integration/misc/webserver_test.go b/gopls/internal/test/integration/misc/webserver_test.go --- a/gopls/internal/test/integration/misc/webserver_test.go 2000-01-01 00:00:00.000000000 -0000 +++ b/gopls/internal/test/integration/misc/webserver_test.go 1970-01-01 00:00:00.000000000 +0000 -@@ -1,229 +0,0 @@ +@@ -1,272 +0,0 @@ -// Copyright 2024 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. @@ -118611,7 +120206,50 @@ diff -urN a/gopls/internal/test/integration/misc/webserver_test.go b/gopls/inter - }) -} - --// viewPkgDoc invokes the "View package documention" code action in +-// TestRenderNavigation tests that the symbol selector and index of +-// symbols are well formed. +-func TestRenderNavigation(t *testing.T) { +- const files = ` +--- go.mod -- +-module example.com +- +--- a/a.go -- +-package a +- +-func Func1(int, string, bool, []string) (int, error) +-func Func2(x, y int, a, b string) (int, error) +- +-type Type struct {} +-func (t Type) Method() {} +-func (p *Type) PtrMethod() {} +- +-func Constructor() Type +-` +- Run(t, files, func(t *testing.T, env *Env) { +- uri1 := viewPkgDoc(t, env, "a/a.go") +- doc := get(t, uri1) +- +- q := regexp.QuoteMeta +- +- // selector +- checkMatch(t, true, doc, q(`