internal/lsp: remove module diagnostics from code actions

With -mod=readonly, all go.mod diagnostics are covered by go get quick
fixes on import statements, so we don't need to run `go mod tidy` on
save for Go files. The real issue with this bug is the call to
WorkspacePackages, which type checks every package in the workspace.

Fixes golang/go#45092

Change-Id: Ibb82a3e58ec345ebdb67c0cbef5e029dce2d5a30
Reviewed-on: https://go-review.googlesource.com/c/tools/+/303149
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
This commit is contained in:
Rebecca Stambler 2021-03-18 12:03:27 -10:00
parent 9b614f5d7b
commit 2c4a88659b
1 changed files with 0 additions and 13 deletions

View File

@ -138,19 +138,6 @@ func (s *Server) codeAction(ctx context.Context, params *protocol.CodeActionPara
return nil, err
}
fileDiags := append(pkgDiagnostics[uri], analysisDiags[uri]...)
modURI := snapshot.GoModForFile(fh.URI())
if modURI != "" {
modFH, err := snapshot.GetVersionedFile(ctx, modURI)
if err != nil {
return nil, err
}
modDiags, err := mod.DiagnosticsForMod(ctx, snapshot, modFH)
if err != nil && !source.IsNonFatalGoModError(err) {
// Not a fatal error.
event.Error(ctx, "module suggested fixes failed", err, tag.Directory.Of(snapshot.View().Folder()))
}
fileDiags = append(fileDiags, modDiags...)
}
// Split diagnostics into fixes, which must match incoming diagnostics,
// and non-fixes, which must match the requested range. Build actions