-
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.
gopls/internal/lsp/cache: better import path hygiene
An import path is not the same as a package path. For example, the declaration: import "example.com/foo" may load a package whose PkgPath() is "vendor/example.com/foo". There was a comment hinting at this in load.go. This change introduces the concept of ImportPath as a distinct type from PackagePath, and documents clearly throughout the relevant APIs which one is expected. Notes: - Metadata.PkgPath is consistently set from the PackagePath, not sometimes (when a root) from PackagePath and sometimes (when indirectly loaded) from an arbitrary ImportPath that resolves to it. I expect this means some packages will now (correctly) appear to be called "vendor/example.com/foo" in the user interface where previously the vendor prefix was omitted. - Metadata.Deps is gone. - Metadata.Imports is a new map from ImportPath to ID. - Metadata.MissingDeps is now a set of ImportPath. - the package loading key is now based on a hash of unique imports. (Duplicates would cancel out.) - The ImporterFunc no longer needs the guesswork of resolveImportPath, since 'go list' already told us the correct answer. - Package.GetImport is renamed DirectDep(packagePath) to avoid the suggestion that it accepts an ImportPath. - Package.ResolveImportPath is the analogous method for import paths. Most clients seem to want this. Change-Id: I4999709120fff4663ba8669358fe149f1626bb8e Reviewed-on: https://go-review.googlesource.com/c/tools/+/443636 Run-TryBot: Alan Donovan <adonovan@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
- Loading branch information
Showing
18 changed files
with
213 additions
and
150 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
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
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
Oops, something went wrong.