-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/lsp/cache: move metadata fields to a new metadataGraph type
In preparation for making metadata immutable, move metadata-related fields to a new MetadataGraph type. Other than instantiating this type when cloning, this CL contains no functional changes. For golang/go#45686 Change-Id: I7ad29d1f331ba7e53dad3f012ad7ecdae4f7d4b7 Reviewed-on: https://go-review.googlesource.com/c/tools/+/340730 Run-TryBot: Robert Findley <[email protected]> gopls-CI: kokoro <[email protected]> Reviewed-by: Alan Donovan <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
- Loading branch information
Showing
4 changed files
with
77 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2022 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package cache | ||
|
||
import "golang.org/x/tools/internal/span" | ||
|
||
// A metadataGraph holds information about a transtively closed import graph of | ||
// Go packages, as obtained from go/packages. | ||
// | ||
// Currently a new metadata graph is created for each snapshot. | ||
// TODO(rfindley): make this type immutable, so that it may be shared across | ||
// snapshots. | ||
type metadataGraph struct { | ||
// ids maps file URIs to package IDs. A single file may belong to multiple | ||
// packages due to tests packages. | ||
ids map[span.URI][]PackageID | ||
|
||
// metadata maps package IDs to their associated metadata. | ||
metadata map[PackageID]*KnownMetadata | ||
|
||
// importedBy maps package IDs to the list of packages that import them. | ||
importedBy map[PackageID][]PackageID | ||
} | ||
|
||
func NewMetadataGraph() *metadataGraph { | ||
return &metadataGraph{ | ||
ids: make(map[span.URI][]PackageID), | ||
metadata: make(map[PackageID]*KnownMetadata), | ||
importedBy: make(map[PackageID][]PackageID), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters