Skip to content

Commit f477bf4

Browse files
adonovangopherbot
authored andcommitted
gopls/internal/lsp/source/completion: avoid Snapshot.CachedPackages
This change removes the last use of CachedPackages, from unimported completions. Instead, we find candidates in the workspace using the metadata, then perform a quick parse of each file to extract the names of exported package members. The quick parse first uses the scanner to find the function bodies and then deletes them, eliminating most of the input to the actual scanner. Unfortunately we can't simply load export data for the relevant package (which should be quick) and use its type information in the usual way, because the deep completion machinery is tightly coupled to the notion of a single realm of objects. We can only display syntactic information (e.g. var/func/const/type). Thus this change is a slight functional regression from the old behavior which presented accurate type information. Fixes golang/go#58663 Change-Id: Ia750785f51ea82ddea7c7849c2565ed6394df467 Reviewed-on: https://go-review.googlesource.com/c/tools/+/472183 Auto-Submit: Alan Donovan <[email protected]> Reviewed-by: Robert Findley <[email protected]> Run-TryBot: Alan Donovan <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent b72edd1 commit f477bf4

File tree

11 files changed

+333
-122
lines changed

11 files changed

+333
-122
lines changed

gopls/internal/lsp/cache/snapshot.go

-8
Original file line numberDiff line numberDiff line change
@@ -1113,14 +1113,6 @@ func (s *snapshot) AllMetadata(ctx context.Context) ([]*source.Metadata, error)
11131113
return meta, nil
11141114
}
11151115

1116-
func (s *snapshot) CachedPackages(ctx context.Context) []source.Package {
1117-
// Cached packages do not make sense with incremental gopls.
1118-
//
1119-
// TODO(golang/go#58663): re-implement unimported completions to not depend
1120-
// on cached import paths.
1121-
return nil
1122-
}
1123-
11241116
// TODO(rfindley): clarify that this is only active modules. Or update to just
11251117
// use findRootPattern.
11261118
func (s *snapshot) GoModForFile(uri span.URI) span.URI {

0 commit comments

Comments
 (0)