1
0
mirror of https://github.com/golang/go synced 2024-11-18 19:14:40 -07:00
go/internal/lsp/cache
Muir Manders 7bb885034f internal/lsp/source: fix completion in empty switch statements
Now we properly offer "case" and "default" keyword completion in cases
like:

    switch {
      <>
    }

First I had to add an AST fix for empty switch statements to move the
closing brace down. For example, say the user is completing:

    switch {
    ca<>
    }

This gets parsed as:

    switch {
    }

Even if we manually recover the "ca" token, "<>" is not positioned
inside the switch statement anymore, so we don't know to offer "case"
and "default" candidates. To work around this, we move the closing
brace down one line yielding:

    switch {

    }

Second I had to add logic to manually extract the completion prefix
inside empty switch statements, and finally some logic to offer (only)
"case" and "default" candidates in empty switch statements.

Updates golang/go#34009.

Change-Id: I624f17da1c5e73faf91fe5f69e872d86f1cf5482
Reviewed-on: https://go-review.googlesource.com/c/tools/+/220579
Run-TryBot: Muir Manders <muir@mnd.rs>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-03-11 03:54:16 +00:00
..
analysis.go internal/lsp/cache: hardcode parse modes instead of guessing them 2020-02-07 20:00:15 +00:00
cache.go internal/lsp: move the debug.Instance onto the Context 2020-03-03 22:54:53 +00:00
check.go internal/lsp: add a test for internal imports handling 2020-02-25 18:38:19 +00:00
debug.go internal/lsp/lsprpc: add a handshake between forwarder and remote 2020-02-24 22:51:04 +00:00
error_test.go internal/lsp: refactor error handling code in type-checking 2019-10-21 18:57:46 +00:00
errors.go internal/span,lsp: disambiguate URIs, DocumentURIs, and paths 2020-02-14 22:51:03 +00:00
external.go internal/lsp: check that a file handle is unmodified before read 2020-01-23 20:52:07 +00:00
load.go internal/lsp: add module versions from "go list" to pkg.go.dev links 2020-02-19 19:55:21 +00:00
mod.go internal/lsp/cache/mod: return errors only within ModHandle and ModTidyHandle 2020-03-06 19:16:17 +00:00
parse.go internal/lsp/source: fix completion in empty switch statements 2020-03-11 03:54:16 +00:00
pkg.go internal/lsp: add module versions from "go list" to pkg.go.dev links 2020-02-19 19:55:21 +00:00
session.go internal/lsp/cache: include session IDs in some cache keys 2020-03-05 20:50:14 +00:00
snapshot.go internal/lsp/cache: fix NPE in fileWasSaved 2020-03-05 18:53:22 +00:00
view.go internal/lsp: move the debug.Instance onto the Context 2020-03-03 22:54:53 +00:00