gopls/internal/lsp/source: references: restrict search to workspace packages

This change restricts the scope of the search to workspace
packages so that we don't report irrelevant references,
and more importantly, spend a lot of time type-checking them.

Conceptually, we simply call call snapshot.WorkspaceMetadata
and intersect the resulits of the ReverseDependency operations
with it.

However, the diff is somewhat trickier because it merges the
old call to snapshot.WorkspaceMetadata within expandMethodSearch
into the new one, and downgrades 'expansions' into a set of IDs
so that expandMethodSearch needn't trade in Metadatas.
It also factors the removal of intermediate test variants
that was previously done in two places, by applying it
to the workspace set.

Casual testing (searching for refs to os.File.Close in
kubernetes, using the CLI tool which performs an IWL)
suggests that it is >2x faster:
v0.11.0 = 35s; master = 20s; this CL = 14s.

Also, a test.

Fixes golang/go#59674

Change-Id: I58c072af7f878f4d64ceffd5b62a68bc3e5daae4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/487017
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Alan Donovan <adonovan@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
diff --git a/gopls/internal/lsp/cache/snapshot.go b/gopls/internal/lsp/cache/snapshot.go
index 6557a0c..cf2b930 100644
--- a/gopls/internal/lsp/cache/snapshot.go
+++ b/gopls/internal/lsp/cache/snapshot.go
@@ -126,7 +126,7 @@
 	analyses *persistent.Map // from analysisKey to analysisPromise
 
 	// workspacePackages contains the workspace's packages, which are loaded
-	// when the view is created.
+	// when the view is created. It contains no intermediate test variants.
 	workspacePackages map[PackageID]PackagePath
 
 	// shouldLoad tracks packages that need to be reloaded, mapping a PackageID