mirror of
https://github.com/golang/go
synced 2024-11-18 16:54:43 -07:00
internal/lsp: add a field on the package to store diagnostics
So we can surface their code actions later. Change-Id: I735e5d025a1250861d49db227f5a79453f599140 Reviewed-on: https://go-review.googlesource.com/c/tools/+/182837 Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
c152035a7b
commit
8b2b8cf54a
15
internal/lsp/cache/pkg.go
vendored
15
internal/lsp/cache/pkg.go
vendored
@ -36,6 +36,9 @@ type pkg struct {
|
||||
// and analysis-to-analysis (horizontal) dependencies.
|
||||
mu sync.Mutex
|
||||
analyses map[*analysis.Analyzer]*analysisEntry
|
||||
|
||||
diagMu sync.Mutex
|
||||
diagnostics []analysis.Diagnostic
|
||||
}
|
||||
|
||||
// packageID is a type that abstracts a package ID.
|
||||
@ -184,3 +187,15 @@ func (pkg *pkg) GetImport(pkgPath string) source.Package {
|
||||
// Don't return a nil pointer because that still satisfies the interface.
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pkg *pkg) SetDiagnostics(diags []analysis.Diagnostic) {
|
||||
pkg.diagMu.Lock()
|
||||
defer pkg.diagMu.Unlock()
|
||||
pkg.diagnostics = diags
|
||||
}
|
||||
|
||||
func (pkg *pkg) GetDiagnostics() []analysis.Diagnostic {
|
||||
pkg.diagMu.Lock()
|
||||
defer pkg.diagMu.Unlock()
|
||||
return pkg.diagnostics
|
||||
}
|
||||
|
@ -303,6 +303,7 @@ func runAnalyses(ctx context.Context, v View, pkg Package, disabledAnalyses map[
|
||||
return err
|
||||
}
|
||||
}
|
||||
pkg.SetDiagnostics(r.diagnostics)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -248,6 +248,8 @@ type Package interface {
|
||||
IsIllTyped() bool
|
||||
GetActionGraph(ctx context.Context, a *analysis.Analyzer) (*Action, error)
|
||||
GetImport(pkgPath string) Package
|
||||
GetDiagnostics() []analysis.Diagnostic
|
||||
SetDiagnostics(diags []analysis.Diagnostic)
|
||||
}
|
||||
|
||||
// TextEdit represents a change to a section of a document.
|
||||
|
Loading…
Reference in New Issue
Block a user