Skip to content

Commit

Permalink
[gopls-release-branch.0.4] internal/lsp: check if analysis enabled in…
Browse files Browse the repository at this point in the history
… convenience fixes

Change-Id: I49c7808ee07340cea0381f324b1fb113ec405213
Reviewed-on: https://go-review.googlesource.com/c/tools/+/241519
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
(cherry picked from commit 7370b03)
Reviewed-on: https://go-review.googlesource.com/c/tools/+/241522
  • Loading branch information
stamblerre committed Jul 8, 2020
1 parent acea1ab commit 6004c85
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/lsp/code_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ func findSourceError(ctx context.Context, snapshot source.Snapshot, pkgID string
func convenienceFixes(ctx context.Context, snapshot source.Snapshot, ph source.PackageHandle, uri span.URI, rng protocol.Range) ([]protocol.CodeAction, error) {
var analyzers []*analysis.Analyzer
for _, a := range snapshot.View().Options().ConvenienceAnalyzers {
if !a.Enabled(snapshot) {
continue
}
analyzers = append(analyzers, a.Analyzer)
}
diagnostics, err := snapshot.Analyze(ctx, ph.ID(), analyzers...)
Expand Down
5 changes: 5 additions & 0 deletions internal/lsp/tests/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,11 @@ func EnableAllAnalyzers(snapshot source.Snapshot, opts *source.Options) {
opts.UserEnabledAnalyses[a.Analyzer.Name] = true
}
}
for _, a := range opts.ConvenienceAnalyzers {
if !a.Enabled(snapshot) {
opts.UserEnabledAnalyses[a.Analyzer.Name] = true
}
}
}

func Diff(want, got string) string {
Expand Down

0 comments on commit 6004c85

Please sign in to comment.