From afd84280124f1e3c3d100fd40838306752d28c40 Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Mon, 12 Feb 2024 17:01:14 -0500 Subject: [PATCH] gopls/internal/test/integration: slightly more ergonomic FolderSettings After setting CL 563475 for autosubmit, I realized we should use a slightly more ergonomic pattern for configuring folder settings. Change-Id: I3a4e9e3dca3f4865c3bca02258cd81ff2b7024b3 Reviewed-on: https://go-review.googlesource.com/c/tools/+/563402 Reviewed-by: Alan Donovan LUCI-TryBot-Result: Go LUCI Auto-Submit: Robert Findley --- .../test/integration/misc/configuration_test.go | 4 ++-- gopls/internal/test/integration/options.go | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gopls/internal/test/integration/misc/configuration_test.go b/gopls/internal/test/integration/misc/configuration_test.go index fff4576bc5b..c6ed18041ae 100644 --- a/gopls/internal/test/integration/misc/configuration_test.go +++ b/gopls/internal/test/integration/misc/configuration_test.go @@ -78,13 +78,13 @@ type B struct { WithOptions( WorkspaceFolders("a"), - FolderSettings(map[string]Settings{ + FolderSettings{ "a": { "analyses": map[string]bool{ "composites": false, }, }, - }), + }, ).Run(t, files, func(t *testing.T, env *Env) { env.OpenFile("a/a.go") env.AfterChange(NoDiagnostics()) diff --git a/gopls/internal/test/integration/options.go b/gopls/internal/test/integration/options.go index a6c394e3467..f1d5425d807 100644 --- a/gopls/internal/test/integration/options.go +++ b/gopls/internal/test/integration/options.go @@ -115,16 +115,16 @@ func WorkspaceFolders(relFolders ...string) RunOption { // // Use in conjunction with WorkspaceFolders to have different settings for // different folders. -func FolderSettings(folderSettings map[string]Settings) RunOption { +type FolderSettings map[string]Settings + +func (fs FolderSettings) set(opts *runConfig) { // Re-use the Settings type, for symmetry, but translate back into maps for // the editor config. folders := make(map[string]map[string]any) - for k, v := range folderSettings { + for k, v := range fs { folders[k] = v } - return optionSetter(func(opts *runConfig) { - opts.editor.FolderSettings = folders - }) + opts.editor.FolderSettings = folders } // EnvVars sets environment variables for the LSP session. When applying these