Skip to content

Commit 50a6ef6

Browse files
findleyrgopherbot
authored andcommitted
gopls/internal/lsp: only diagnose one package per file
The purpose of diagnosing changed files is to compute local diagnostics with low latency. We only need one package for that. Don't slow everything down by doing redundant and unnecessary work checking test variants. For golang/go#60926 Change-Id: I3d77305d5732fb0036e4865bbe7311d1561f2fd5 Reviewed-on: https://go-review.googlesource.com/c/tools/+/509876 Auto-Submit: Robert Findley <[email protected]> Run-TryBot: Robert Findley <[email protected]> Reviewed-by: Alan Donovan <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 48026e1 commit 50a6ef6

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

gopls/internal/lsp/cache/check.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ func (s *snapshot) resolveImportGraph() (*importGraph, error) {
193193
ctx, done := event.Start(event.Detach(ctx), "cache.resolveImportGraph")
194194
defer done()
195195

196-
if err := s.awaitLoaded(ctx); err != nil {
196+
if err := s.awaitLoaded(ctx); err != nil { // TODO(rfindley): this is problematic, and slows down diagnostics
197197
return nil, err
198198
}
199199

gopls/internal/lsp/diagnostics.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ func (s *Server) diagnoseChangedFiles(ctx context.Context, snapshot source.Snaps
230230
}
231231

232232
// Find all packages that include this file and diagnose them in parallel.
233-
metas, err := snapshot.MetadataForFile(ctx, uri)
233+
meta, err := source.NarrowestMetadataForFile(ctx, snapshot, uri)
234234
if err != nil {
235235
if ctx.Err() != nil {
236236
return
@@ -240,10 +240,7 @@ func (s *Server) diagnoseChangedFiles(ctx context.Context, snapshot source.Snaps
240240
// noisy to log (and we'll handle things later in the slow pass).
241241
continue
242242
}
243-
source.RemoveIntermediateTestVariants(&metas)
244-
for _, m := range metas {
245-
toDiagnose[m.ID] = m
246-
}
243+
toDiagnose[meta.ID] = meta
247244
}
248245
s.diagnosePkgs(ctx, snapshot, toDiagnose, nil)
249246
}

0 commit comments

Comments
 (0)