Skip to content

Commit 3f74dc5

Browse files
committed
gopls/internal/settings: remove experiments
Remove the concept of "experiments" from gopls settings and testing. In the past, this was a way for us to selectively enable features in the VS Code nightly build, but we have since switched to a model where we cut earlier prereleases and endeavor to have more prerelease testing. Fixes golang/go#65548 Change-Id: I64d739dd4b4899c19ce5cd0c3da45e498e9ae417 Reviewed-on: https://go-review.googlesource.com/c/tools/+/579395 Auto-Submit: Robert Findley <[email protected]> Reviewed-by: Alan Donovan <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent e716599 commit 3f74dc5

File tree

6 files changed

+15
-97
lines changed

6 files changed

+15
-97
lines changed

gopls/internal/settings/settings.go

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ import (
1111
"strings"
1212
"time"
1313

14-
"golang.org/x/tools/gopls/internal/analysis/unusedvariable"
1514
"golang.org/x/tools/gopls/internal/file"
1615
"golang.org/x/tools/gopls/internal/protocol"
17-
"golang.org/x/tools/gopls/internal/protocol/command"
1816
)
1917

2018
type Annotation string
@@ -608,24 +606,10 @@ func SetOptions(options *Options, opts any) OptionResults {
608606
switch opts := opts.(type) {
609607
case nil:
610608
case map[string]any:
611-
// If the user's settings contains "allExperiments", set that first,
612-
// and then let them override individual settings independently.
613-
var enableExperiments bool
614-
for name, value := range opts {
615-
if b, ok := value.(bool); name == "allExperiments" && ok && b {
616-
enableExperiments = true
617-
options.EnableAllExperiments()
618-
}
619-
}
620609
seen := map[string]struct{}{}
621610
for name, value := range opts {
622611
results = append(results, options.set(name, value, seen))
623612
}
624-
// Finally, enable any experimental features that are specified in
625-
// maps, which allows users to individually toggle them on or off.
626-
if enableExperiments {
627-
options.enableAllExperimentMaps()
628-
}
629613
default:
630614
results = append(results, OptionResult{
631615
Value: opts,
@@ -694,8 +678,7 @@ func (o *Options) Clone() *Options {
694678
ServerOptions: o.ServerOptions,
695679
UserOptions: o.UserOptions,
696680
}
697-
// Fully clone any slice or map fields. Only Hooks, ExperimentalOptions,
698-
// and UserOptions can be modified.
681+
// Fully clone any slice or map fields. Only UserOptions can be modified.
699682
copyStringMap := func(src map[string]bool) map[string]bool {
700683
dst := make(map[string]bool)
701684
for k, v := range src {
@@ -719,25 +702,6 @@ func (o *Options) Clone() *Options {
719702
return result
720703
}
721704

722-
// EnableAllExperiments turns on all of the experimental "off-by-default"
723-
// features offered by gopls. Any experimental features specified in maps
724-
// should be enabled in enableAllExperimentMaps.
725-
func (o *Options) EnableAllExperiments() {
726-
o.SemanticTokens = true
727-
}
728-
729-
func (o *Options) enableAllExperimentMaps() {
730-
if _, ok := o.Codelenses[string(command.GCDetails)]; !ok {
731-
o.Codelenses[string(command.GCDetails)] = true
732-
}
733-
if _, ok := o.Codelenses[string(command.RunGovulncheck)]; !ok {
734-
o.Codelenses[string(command.RunGovulncheck)] = true
735-
}
736-
if _, ok := o.Analyses[unusedvariable.Analyzer.Name]; !ok {
737-
o.Analyses[unusedvariable.Analyzer.Name] = true
738-
}
739-
}
740-
741705
// validateDirectoryFilter validates if the filter string
742706
// - is not empty
743707
// - start with either + or -
@@ -1034,8 +998,12 @@ func (o *Options) set(name string, value interface{}, seen map[string]struct{})
1034998
result.setStringSlice(&o.StandaloneTags)
1035999

10361000
case "allExperiments":
1037-
// This setting should be handled before all of the other options are
1038-
// processed, so do nothing here.
1001+
// golang/go#65548: this setting is a no-op, but we fail don't report it as
1002+
// deprecated, since the nightly VS Code injects it.
1003+
//
1004+
// If, in the future, VS Code stops injecting this, we could theoretically
1005+
// report an error here, but it also seems harmless to keep ignoring this
1006+
// setting forever.
10391007

10401008
case "newDiff":
10411009
result.deprecated("")

gopls/internal/test/integration/debug/debug_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TestBugNotification(t *testing.T) {
3939
// start the internal web server.
4040
func TestStartDebugging(t *testing.T) {
4141
WithOptions(
42-
Modes(Default|Experimental), // doesn't work in Forwarded mode
42+
Modes(Default), // doesn't work in Forwarded mode
4343
).Run(t, "", func(t *testing.T, env *Env) {
4444
// Start a debugging server.
4545
res, err := startDebugging(env.Ctx, env.Editor.Server, &command.DebuggingArgs{

gopls/internal/test/integration/diagnostics/diagnostics_test.go

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
. "golang.org/x/tools/gopls/internal/test/integration"
1616
"golang.org/x/tools/gopls/internal/test/integration/fake"
1717
"golang.org/x/tools/gopls/internal/util/bug"
18-
"golang.org/x/tools/gopls/internal/util/goversion"
1918
"golang.org/x/tools/internal/testenv"
2019
)
2120

@@ -1384,36 +1383,6 @@ func _() {
13841383
})
13851384
}
13861385

1387-
func TestEnableAllExperiments(t *testing.T) {
1388-
// Before the oldest supported Go version, gopls sends a warning to upgrade
1389-
// Go, which fails the expectation below.
1390-
testenv.NeedsGo1Point(t, goversion.OldestSupported())
1391-
1392-
const mod = `
1393-
-- go.mod --
1394-
module mod.com
1395-
1396-
go 1.12
1397-
-- main.go --
1398-
package main
1399-
1400-
import "bytes"
1401-
1402-
func b(c bytes.Buffer) {
1403-
_ = 1
1404-
}
1405-
`
1406-
WithOptions(
1407-
Settings{"allExperiments": true},
1408-
).Run(t, mod, func(t *testing.T, env *Env) {
1409-
// Confirm that the setting doesn't cause any warnings.
1410-
env.OnceMet(
1411-
InitialWorkspaceLoad,
1412-
NoShownMessage(""), // empty substring to match any message
1413-
)
1414-
})
1415-
}
1416-
14171386
func TestSwig(t *testing.T) {
14181387
if _, err := exec.LookPath("swig"); err != nil {
14191388
t.Skip("skipping test: swig not available")

gopls/internal/test/integration/misc/semantictokens_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ func main() {}
3030
`
3131
WithOptions(
3232
Modes(Default),
33-
Settings{"allExperiments": true},
3433
).Run(t, src, func(t *testing.T, env *Env) {
3534
params := &protocol.SemanticTokensParams{}
3635
const badURI = "http://foo"

gopls/internal/test/integration/regtest.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ func (r RunMultiple) Run(t *testing.T, files string, f TestFunc) {
9797
func DefaultModes() Mode {
9898
modes := Default
9999
if !testing.Short() {
100-
modes |= Experimental | Forwarded
100+
// TODO(rfindley): we should just run a few select integration tests in
101+
// "Forwarded" mode, and call it a day. No need to run every single test in
102+
// two ways.
103+
modes |= Forwarded
101104
}
102105
if *runSubprocessTests {
103106
modes |= SeparateProcess

gopls/internal/test/integration/runner.go

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"golang.org/x/tools/gopls/internal/debug"
2525
"golang.org/x/tools/gopls/internal/lsprpc"
2626
"golang.org/x/tools/gopls/internal/protocol"
27-
"golang.org/x/tools/gopls/internal/settings"
2827
"golang.org/x/tools/gopls/internal/test/integration/fake"
2928
"golang.org/x/tools/internal/jsonrpc2"
3029
"golang.org/x/tools/internal/jsonrpc2/servertest"
@@ -45,17 +44,15 @@ import (
4544
// TODO(rfindley, cleanup): rather than using arbitrary names for these modes,
4645
// we can compose them explicitly out of the features described here, allowing
4746
// individual tests more freedom in constructing problematic execution modes.
48-
// For example, a test could assert on a certain behavior when running with
49-
// experimental options on a separate process. Moreover, we could unify 'Modes'
50-
// with 'Options', and use RunMultiple rather than a hard-coded loop through
51-
// modes.
47+
// For example, a test could assert on a certain behavior when running on a
48+
// separate process. Moreover, we could unify 'Modes' with 'Options', and use
49+
// RunMultiple rather than a hard-coded loop through modes.
5250
//
5351
// Mode | Options | Shared Cache? | Shared Server? | In-process?
5452
// ---------------------------------------------------------------------------
5553
// Default | Default | Y | N | Y
5654
// Forwarded | Default | Y | Y | Y
5755
// SeparateProcess | Default | Y | Y | N
58-
// Experimental | Experimental | N | N | Y
5956
type Mode int
6057

6158
const (
@@ -76,13 +73,6 @@ const (
7673
//
7774
// Only supported on GOOS=linux.
7875
SeparateProcess
79-
80-
// Experimental enables all of the experimental configurations that are
81-
// being developed, and runs gopls in sidecar mode.
82-
//
83-
// It uses a separate cache for each test, to exercise races that may only
84-
// appear with cache misses.
85-
Experimental
8676
)
8777

8878
func (m Mode) String() string {
@@ -93,8 +83,6 @@ func (m Mode) String() string {
9383
return "forwarded"
9484
case SeparateProcess:
9585
return "separate process"
96-
case Experimental:
97-
return "experimental"
9886
default:
9987
return "unknown mode"
10088
}
@@ -151,7 +139,6 @@ func (r *Runner) Run(t *testing.T, files string, test TestFunc, opts ...RunOptio
151139
{"default", Default, r.defaultServer},
152140
{"forwarded", Forwarded, r.forwardedServer},
153141
{"separate_process", SeparateProcess, r.separateProcessServer},
154-
{"experimental", Experimental, r.experimentalServer},
155142
}
156143

157144
for _, tc := range tests {
@@ -349,14 +336,6 @@ func (r *Runner) defaultServer() jsonrpc2.StreamServer {
349336
return lsprpc.NewStreamServer(cache.New(r.store), false, nil)
350337
}
351338

352-
// experimentalServer handles the Experimental execution mode.
353-
func (r *Runner) experimentalServer() jsonrpc2.StreamServer {
354-
options := func(o *settings.Options) {
355-
o.EnableAllExperiments()
356-
}
357-
return lsprpc.NewStreamServer(cache.New(nil), false, options)
358-
}
359-
360339
// forwardedServer handles the Forwarded execution mode.
361340
func (r *Runner) forwardedServer() jsonrpc2.StreamServer {
362341
r.tsOnce.Do(func() {

0 commit comments

Comments
 (0)