1
0
mirror of https://github.com/golang/go synced 2024-11-18 18:34:40 -07:00
go/internal/lsp/source
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
..
comment_test.go internal/lsp: convert comments to markdown before sending to client 2019-10-04 18:35:38 +00:00
comment.go internal/lsp: convert comments to markdown before sending to client 2019-10-04 18:35:38 +00:00
completion_builtin.go internal/lsp/source: untangle completion type comparison 2020-02-24 18:12:40 +00:00
completion_format.go internal/span,lsp: disambiguate URIs, DocumentURIs, and paths 2020-02-14 22:51:03 +00:00
completion_keywords.go internal/lsp/source: support completing "range" keyword 2020-03-08 01:35:34 +00:00
completion_labels.go internal/lsp: sort by label after score 2019-12-30 21:11:21 +00:00
completion_literal.go internal/lsp/source: untangle completion type comparison 2020-02-24 18:12:40 +00:00
completion_snippet.go internal/lsp: merge completion options into source.Options 2020-01-13 20:09:44 +00:00
completion_statements.go internal/lsp/source: offer completion "if err != nil { return err }" 2020-03-10 21:06:53 +00:00
completion.go internal/lsp/source: offer completion "if err != nil { return err }" 2020-03-10 21:06:53 +00:00
deep_completion.go internal/lsp/source: improve completion involving multiple return values 2020-02-06 05:07:08 +00:00
diagnostics.go internal/lsp: fix concurrent map read/write for missingmodules 2020-03-03 19:46:16 +00:00
folding_range.go internal/lsp/cache: add file contents to ParseGoHandle 2020-02-13 05:05:14 +00:00
format_test.go internal/lsp/source: trim file very carefully 2020-01-17 20:34:13 +00:00
format.go internal/lsp: fix diagnostics not clearing when creating new files 2020-02-13 21:50:53 +00:00
highlight.go internal/lsp/cache: add file contents to ParseGoHandle 2020-02-13 05:05:14 +00:00
hover.go internal/lsp/source: return location(s) for imported packages 2020-03-09 16:25:02 +00:00
identifier.go internal/lsp/source: return location(s) for imported packages 2020-03-09 16:25:02 +00:00
implementation.go internal/lsp/source: support inverse "implementations" 2020-03-02 21:28:54 +00:00
options.go internal/lsp: support when hierarchicalDocumentSymbolSupport is false 2020-03-06 18:17:37 +00:00
references.go internal/lsp: don't return references for builtins 2020-02-06 19:49:06 +00:00
rename_check.go internal/lsp: improve literal func completion candidates 2019-11-07 21:18:00 +00:00
rename.go internal/lsp: permit renaming symbols declared in other packages 2020-01-27 18:56:10 +00:00
signature_help.go internal/lsp/source: return location(s) for imported packages 2020-03-09 16:25:02 +00:00
source_test.go internal/lsp/source: return location(s) for imported packages 2020-03-09 16:25:02 +00:00
symbols.go internal/lsp/cache: add file contents to ParseGoHandle 2020-02-13 05:05:14 +00:00
util.go internal/lsp/source: offer completion "if err != nil { return err }" 2020-03-10 21:06:53 +00:00
view.go internal/lsp/cache: include session IDs in some cache keys 2020-03-05 20:50:14 +00:00
workspace_symbol.go internal/lsp/source: use logical filenames for workspace symbols 2020-03-04 19:39:43 +00:00