Skip to content

Commit 6004c85

Browse files
committed
[gopls-release-branch.0.4] internal/lsp: check if analysis enabled in convenience fixes
Change-Id: I49c7808ee07340cea0381f324b1fb113ec405213 Reviewed-on: https://go-review.googlesource.com/c/tools/+/241519 Run-TryBot: Rebecca Stambler <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Heschi Kreinick <[email protected]> (cherry picked from commit 7370b03) Reviewed-on: https://go-review.googlesource.com/c/tools/+/241522
1 parent acea1ab commit 6004c85

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

internal/lsp/code_action.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,9 @@ func findSourceError(ctx context.Context, snapshot source.Snapshot, pkgID string
349349
func convenienceFixes(ctx context.Context, snapshot source.Snapshot, ph source.PackageHandle, uri span.URI, rng protocol.Range) ([]protocol.CodeAction, error) {
350350
var analyzers []*analysis.Analyzer
351351
for _, a := range snapshot.View().Options().ConvenienceAnalyzers {
352+
if !a.Enabled(snapshot) {
353+
continue
354+
}
352355
analyzers = append(analyzers, a.Analyzer)
353356
}
354357
diagnostics, err := snapshot.Analyze(ctx, ph.ID(), analyzers...)

internal/lsp/tests/util.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,11 @@ func EnableAllAnalyzers(snapshot source.Snapshot, opts *source.Options) {
516516
opts.UserEnabledAnalyses[a.Analyzer.Name] = true
517517
}
518518
}
519+
for _, a := range opts.ConvenienceAnalyzers {
520+
if !a.Enabled(snapshot) {
521+
opts.UserEnabledAnalyses[a.Analyzer.Name] = true
522+
}
523+
}
519524
}
520525

521526
func Diff(want, got string) string {

0 commit comments

Comments
 (0)