1
0
mirror of https://github.com/golang/go synced 2024-09-30 22:58:34 -06:00
go/internal/lsp
Muir Manders 138c814f66 internal/lsp/source: offer completion "if err != nil { return err }"
Now we offer an error-check-and-return completion candidate when
appropriate:

    func myFunc() (int, error) {
      f, err := os.Open("foo")
      <>
    }

offers the candidate:

    if err != nil {
      return 0, <err>
    }

where <> denotes a placeholder so you can easily alter "err".

The completion will only be offered when:
1. The position is in a function that returns an error as final result
   value, and
2. The statement preceding position is an assignment whose final LHS
   value is an error.

The completion will contain zero values for the non-error return values
as necessary.

Using the above example, the completion will be offered after the user
has typed:

    i
    if
    if err

Basically the candidate will be offered after every keystroke as the
user types "if err".

I call this new type of completion a statement completion - perfect
for when you want to make a statement!

Change-Id: I0a330e1c1fa81a2757d3afc84c24e853f46f26b0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/221613
Run-TryBot: Muir Manders <muir@mnd.rs>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-03-10 21:06:53 +00:00
..
browser internal/lsp: add version and bug commands 2019-05-11 04:16:02 +00:00
cache internal/lsp/cache/mod: return errors only within ModHandle and ModTidyHandle 2020-03-06 19:16:17 +00:00
cmd internal/lsp: support when hierarchicalDocumentSymbolSupport is false 2020-03-06 18:17:37 +00:00
debug internal/lsp: bring generated protocol code up to date; stop corrupting logs 2020-03-09 20:21:50 +00:00
diff internal/span,lsp: disambiguate URIs, DocumentURIs, and paths 2020-02-14 22:51:03 +00:00
fake internal/lsp/regtest: implement formatting and organizeImports 2020-03-02 19:16:53 +00:00
fuzzy internal/lsp: make golint happy 2019-12-23 18:17:04 +00:00
helper internal/lsp: change to helper.go to output a formatted file 2020-01-31 20:35:38 +00:00
lsprpc internal/lsp/lsprpc: don't connect to sockets owned by different users 2020-03-09 18:08:59 +00:00
mod internal/lsp: support textDocument/formatting for .mod extension 2020-03-06 13:51:27 +00:00
protocol internal/lsp: bring generated protocol code up to date; stop corrupting logs 2020-03-09 20:21:50 +00:00
regtest internal/lsp/protocol: unmarshal to pointers when dispatching requests 2020-03-05 22:45:36 +00:00
snippet all: fix broken links to LSP specification 2019-10-02 18:32:53 +00:00
source internal/lsp/source: offer completion "if err != nil { return err }" 2020-03-10 21:06:53 +00:00
telemetry internal/lsp: log snapshot IDs, don't log context cancellation 2020-01-27 19:20:44 +00:00
testdata internal/lsp/source: offer completion "if err != nil { return err }" 2020-03-10 21:06:53 +00:00
tests internal/lsp: bring generated protocol code up to date; stop corrupting logs 2020-03-09 20:21:50 +00:00
code_action.go internal/lsp: check for file URIs on LSP requests 2020-02-14 22:51:26 +00:00
command.go internal/lsp: add an upgrade all dependencies codelens 2020-03-02 21:30:18 +00:00
completion_test.go internal/span,lsp: disambiguate URIs, DocumentURIs, and paths 2020-02-14 22:51:03 +00:00
completion.go internal/lsp: check for file URIs on LSP requests 2020-02-14 22:51:26 +00:00
definition.go internal/lsp/source: return location(s) for imported packages 2020-03-09 16:25:02 +00:00
diagnostics.go internal/telemetry: remove the concept of a Tagger 2020-03-03 22:56:24 +00:00
folding_range.go internal/lsp: check for file URIs on LSP requests 2020-02-14 22:51:26 +00:00
format.go internal/lsp: support textDocument/formatting for .mod extension 2020-03-06 13:51:27 +00:00
general.go internal/lsp/lsprpc: clean up client session on disconnection 2020-02-24 23:23:05 +00:00
highlight.go internal/lsp: check for file URIs on LSP requests 2020-02-14 22:51:26 +00:00
hover.go internal/lsp: support textDocument/hover for .mod extension 2020-02-26 15:59:49 +00:00
implementation.go internal/lsp: check for file URIs on LSP requests 2020-02-14 22:51:26 +00:00
link.go internal/lsp: support textDocument/documentLink for .mod extension 2020-02-26 15:45:04 +00:00
lsp_test.go internal/lsp: support when hierarchicalDocumentSymbolSupport is false 2020-03-06 18:17:37 +00:00
references.go internal/lsp: check for file URIs on LSP requests 2020-02-14 22:51:26 +00:00
rename.go internal/lsp: check for file URIs on LSP requests 2020-02-14 22:51:26 +00:00
reset_golden.sh internal/lsp: fix regeneration of golden files 2019-09-25 13:16:59 +00:00
server_gen.go internal/lsp: support when hierarchicalDocumentSymbolSupport is false 2020-03-06 18:17:37 +00:00
server.go internal/lsp: add an upgrade all dependencies codelens 2020-03-02 21:30:18 +00:00
signature_help.go internal/lsp: check for file URIs on LSP requests 2020-02-14 22:51:26 +00:00
symbols.go internal/lsp: support when hierarchicalDocumentSymbolSupport is false 2020-03-06 18:17:37 +00:00
text_synchronization.go internal/lsp: clear diagnostics for deleted files 2020-02-19 20:26:41 +00:00
workspace_symbol.go internal/lsp: add support for workspace symbol 2020-02-05 19:03:17 +00:00
workspace.go internal/lsp: generate boilerplate stubs for type Server 2020-01-24 14:41:51 +00:00