internal/lsp: don't store diagnostics for builtin.go

Fixes golang/go#44866

Change-Id: I9606df932c1b35d91816306fbcb48edc5b023b30
GitHub-Last-Rev: e6f525ed46a08ac77eac3af295c2be684405e88b
GitHub-Pull-Request: golang/tools#364
Reviewed-on: https://go-review.googlesource.com/c/tools/+/386219
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Trust: Nooras Saba‎ <saba@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
Matheus Alcantara 2022-02-18 20:34:48 +00:00 committed by Robert Findley
parent 4f21f7a508
commit b7d29496b7
1 changed files with 5 additions and 1 deletions

View File

@ -288,7 +288,11 @@ func (s *Server) diagnosePkg(ctx context.Context, snapshot source.Snapshot, pkg
return return
} }
for _, cgf := range pkg.CompiledGoFiles() { for _, cgf := range pkg.CompiledGoFiles() {
s.storeDiagnostics(snapshot, cgf.URI, typeCheckSource, pkgDiagnostics[cgf.URI]) // builtin.go exists only for documentation purposes, and is not valid Go code.
// Don't report distracting errors
if !snapshot.IsBuiltin(ctx, cgf.URI) {
s.storeDiagnostics(snapshot, cgf.URI, typeCheckSource, pkgDiagnostics[cgf.URI])
}
} }
if includeAnalysis && !pkg.HasListOrParseErrors() { if includeAnalysis && !pkg.HasListOrParseErrors() {
reports, err := source.Analyze(ctx, snapshot, pkg, false) reports, err := source.Analyze(ctx, snapshot, pkg, false)