forked from golang/tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/lsp: handle staticcheck in didChangeConfiguration
As we have modified the ways that we control which analyzers get executed for a given case, we have lost the behavior of enabling and disabling staticcheck smoothly. This CL splits out the staticcheck analyzers from the main group so that the "staticcheck" setting can override whether or not a given staticcheck analysis is enabled. Fixes golang/go#41311 Change-Id: I9c1695afe4a8f89cd0ee50a79e83b2f42a2c20cb Reviewed-on: https://go-review.googlesource.com/c/tools/+/254038 Run-TryBot: Rebecca Stambler <[email protected]> gopls-CI: kokoro <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Robert Findley <[email protected]>
- Loading branch information
1 parent
6422fca
commit 97363e2
Showing
9 changed files
with
174 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// 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 regtest | ||
|
||
import ( | ||
"testing" | ||
|
||
"golang.org/x/tools/internal/lsp" | ||
"golang.org/x/tools/internal/lsp/fake" | ||
) | ||
|
||
// Test that enabling and disabling produces the expected results of showing | ||
// and hiding staticcheck analysis results. | ||
func TestChangeConfiguration(t *testing.T) { | ||
const files = ` | ||
-- go.mod -- | ||
module mod.com | ||
go 1.12 | ||
-- a/a.go -- | ||
package a | ||
// NotThisVariable should really start with ThisVariable. | ||
const ThisVariable = 7 | ||
` | ||
run(t, files, func(t *testing.T, env *Env) { | ||
env.Await( | ||
CompletedWork(lsp.DiagnosticWorkTitle(lsp.FromInitialWorkspaceLoad), 1), | ||
) | ||
env.OpenFile("a/a.go") | ||
env.Await( | ||
CompletedWork(lsp.DiagnosticWorkTitle(lsp.FromDidOpen), 1), | ||
NoDiagnostics("a/a.go"), | ||
) | ||
cfg := &fake.EditorConfig{} | ||
*cfg = env.Editor.Config | ||
cfg.EnableStaticcheck = true | ||
env.changeConfiguration(t, cfg) | ||
env.Await( | ||
DiagnosticAt("a/a.go", 2, 0), | ||
) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.