go/gopls/internal/lsp/source/completion
Alan Donovan 91311ab3b8 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>
2022-10-19 21:54:36 +00:00
..
builtin.go gopls: migrate internal/lsp to gopls/internal/lsp 2022-09-07 16:44:44 +00:00
completion.go gopls/internal/lsp/cache: better import path hygiene 2022-10-19 21:54:36 +00:00
deep_completion.go gopls: migrate internal/lsp to gopls/internal/lsp 2022-09-07 16:44:44 +00:00
deep_completion_test.go gopls: migrate internal/lsp to gopls/internal/lsp 2022-09-07 16:44:44 +00:00
definition.go gopls/internal/span: move internal/span into gopls 2022-10-07 14:50:44 +00:00
format.go gopls/internal/span: move internal/span into gopls 2022-10-07 14:50:44 +00:00
fuzz.go gopls: migrate internal/lsp to gopls/internal/lsp 2022-09-07 16:44:44 +00:00
keywords.go gopls: migrate internal/lsp to gopls/internal/lsp 2022-09-07 16:44:44 +00:00
labels.go gopls: migrate internal/lsp to gopls/internal/lsp 2022-09-07 16:44:44 +00:00
literal.go gopls/internal/lsp/source: don't type-check in FindPackageFromPos 2022-10-05 17:57:07 +00:00
package.go gopls/internal/span: move internal/span into gopls 2022-10-07 14:50:44 +00:00
package_test.go gopls: migrate internal/lsp to gopls/internal/lsp 2022-09-07 16:44:44 +00:00
postfix_snippets.go gopls: migrate internal/lsp to gopls/internal/lsp 2022-09-07 16:44:44 +00:00
printf.go gopls: migrate internal/lsp to gopls/internal/lsp 2022-09-07 16:44:44 +00:00
printf_test.go gopls: migrate internal/lsp to gopls/internal/lsp 2022-09-07 16:44:44 +00:00
snippet.go gopls: migrate internal/lsp to gopls/internal/lsp 2022-09-07 16:44:44 +00:00
statements.go gopls/internal/lsp/cache: better import path hygiene 2022-10-19 21:54:36 +00:00
util.go internal/diff: simplify API, break span dependency 2022-10-05 20:32:15 +00:00
util_test.go gopls: migrate internal/lsp to gopls/internal/lsp 2022-09-07 16:44:44 +00:00