go/gopls/doc
Robert Findley b2533141c6 gopls/internal/lsp/cache: add support for loading standalone main files
Add support in gopls for working on "standalone main files", which are
Go source files that should be treated as standalone packages.
Standalone files are identified by a specific build tag, which may be
configured via the new standaloneTags setting. For example, it is common
to use the directive "//go:build ignore" to colocate standalone files
with other package files.

Specifically,
- add a new loadScope interface for use in snapshot.load, to add a bit
  of type safety
- add a new standaloneTags setting to allow configuring the set of build
  constraints that define standalone main files
- add an isStandaloneFile function that detects standalone files based
  on build constraints
- implement the loading of standalone files, by querying go/packages for
  the standalone file path
- rewrite getOrLoadIDsForURI, which had inconsistent behavior with
  respect to error handling and the experimentalUseInvalidMetadata
  setting
- update the WorkspaceSymbols handler to properly format
  command-line-arguments packages
- add regression tests for LSP behavior with standalone files, and for
  dynamic configuration of standalone files

Fixes golang/go#49657

Change-Id: I7b79257a984a87b67e476c32dec3c122f9bbc636
Reviewed-on: https://go-review.googlesource.com/c/tools/+/441877
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-10-13 15:07:40 +00:00
..
design gopls/internal/span: move internal/span into gopls 2022-10-07 14:50:44 +00:00
advanced.md gopls/doc: update stale documentation on generics 2022-03-29 16:50:19 +00:00
analyzers.md go/analysis/passes/loopclosure: experiment with checking t.Run+Parallel 2022-09-20 22:09:32 +00:00
command-line.md gopls/doc: remove bad gopls cli link 2021-10-20 20:41:51 +00:00
commands.md gopls: add codelens to reset upgrade diagnostics 2022-09-12 15:41:56 +00:00
contributing.md gopls/doc: update stale documentation and improve link names 2022-09-07 18:17:13 +00:00
daemon.md gopls/doc: clarify how to set remote.listen.timeout 2021-03-08 14:22:49 +00:00
emacs.md Update emacs.md - add .dir-locals.el example 2021-03-19 04:40:15 +00:00
features.md gopls: change the default value for templateExtensions to be empty 2022-01-13 20:56:24 +00:00
generate.go gopls: use fmt.Fprintf 2022-10-04 16:29:17 +00:00
generate_test.go gopls/doc: make doc generation work regardless of the current directory 2022-08-31 13:23:24 +00:00
inlayHints.md internal/lsp: update inlay hints documentation to include go snippets 2022-07-26 18:27:49 +00:00
semantictokens.md internal/lsp: produce "method" in place of "member" as per the spec 2021-09-13 21:01:54 +00:00
settings.md gopls/internal/lsp/cache: add support for loading standalone main files 2022-10-13 15:07:40 +00:00
subl.md gopls/doc: how to request a particular gopls w/ sublime text 2022-02-04 21:02:33 +00:00
troubleshooting.md gopls: merge README and user.md 2021-01-21 18:28:06 +00:00
vim.md gopls: Improve auto-imports example for NeoVim LSP 2022-08-09 15:21:58 +00:00
workspace.md gopls: deprecate three experimental features 2022-09-28 16:54:30 +00:00