Skip to content

Commit

Permalink
gopls/internal/test/integration: slightly more ergonomic FolderSettings
Browse files Browse the repository at this point in the history
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 <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Findley <rfindley@google.com>
  • Loading branch information
findleyr authored and gopherbot committed Feb 13, 2024
1 parent c5643e9 commit afd8428
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions gopls/internal/test/integration/misc/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
10 changes: 5 additions & 5 deletions gopls/internal/test/integration/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit afd8428

Please sign in to comment.