1
0
mirror of https://github.com/golang/go synced 2024-09-30 23:08:32 -06:00
go/internal/lsp
Muir Manders 88e652f7a8 internal/lsp/cache: improve completion after dangling selector
Dangling selectors such as:

    func _() {
      x.
    }
    var x struct { i int }

tend to wreak havoc on the AST. In the above example you didn't used
to get completions because the declaration of "x" was missing from the
AST.

We now work around this issue by inserting a "_" into the source code
before parsing to make the selector valid:

    func _() {
      x._ // <-- insert "_" here
    }
    var x struct { i int }

This makes completion work as expected because the declaration of "x"
is present in the AST.

I had to change fixAST() to be called before fixSrc() because
otherwise this new workaround in fixSrc() breaks the "accidental
keyword" countermeasures in fixAST().

Fixes golang/go#31973.
Updates golang/go#31687.

Change-Id: Ia7ef6c045a9c71502d1b8b36f187ac9b8a85fe21
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216484
Run-TryBot: Muir Manders <muir@mnd.rs>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-02-13 22:46:42 +00:00
..
browser internal/lsp: add version and bug commands 2019-05-11 04:16:02 +00:00
cache internal/lsp/cache: improve completion after dangling selector 2020-02-13 22:46:42 +00:00
cmd internal/lsp/source: make matchers selectable in WorkspaceSymbols 2020-02-13 22:46:20 +00:00
debug internal/lsp/debug: fix early closure of logfile 2020-02-11 18:05:03 +00:00
diff internal/lsp: fix unified diffs of edits at the end of a file 2019-10-11 16:38:14 +00:00
fake internal/lsp/lsprpc: add test for definition outside of workspace 2020-02-10 17:53:45 +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: add test for definition outside of workspace 2020-02-10 17:53:45 +00:00
mod internal/lsp/cache: improve ModTidyHandle cache key 2020-02-07 18:07:39 +00:00
protocol internal/lsp: change return type of PrepareRename to *Range 2020-02-13 20:00:52 +00:00
snippet all: fix broken links to LSP specification 2019-10-02 18:32:53 +00:00
source internal/lsp/source: make matchers selectable in WorkspaceSymbols 2020-02-13 22:46:20 +00:00
telemetry internal/lsp: log snapshot IDs, don't log context cancellation 2020-01-27 19:20:44 +00:00
testdata internal/lsp/cache: improve completion after dangling selector 2020-02-13 22:46:42 +00:00
tests internal/lsp/source: make matchers selectable in WorkspaceSymbols 2020-02-13 22:46:20 +00:00
code_action.go internal/lsp: add quickfixes for missing dependencies in go.mod 2020-02-07 00:16:14 +00:00
command.go internal/lsp: build overlays through the snapshot 2020-02-07 18:37:49 +00:00
completion_test.go internal/lsp: filter keyword completions in tests 2020-02-06 05:08:30 +00:00
completion.go internal/lsp: consolidate completion sorting 2020-01-17 20:30:43 +00:00
definition.go internal/lsp: don't show links in hover for test functions 2020-02-03 21:56:10 +00:00
diagnostics.go internal/lsp: don't use overlays from the session in the snapshot 2020-02-07 19:21:16 +00:00
folding_range.go internal/lsp: remove view.FindPosInPackage and view.FindMapperInPackage 2020-01-13 18:51:11 +00:00
format.go internal/lsp: remove view.FindPosInPackage and view.FindMapperInPackage 2020-01-13 18:51:11 +00:00
general.go internal/lsp: add support for workspace symbol 2020-02-05 19:03:17 +00:00
highlight.go internal/lsp: remove view.FindPosInPackage and view.FindMapperInPackage 2020-01-13 18:51:11 +00:00
hover.go internal/lsp: don't show links in hover for test functions 2020-02-03 21:56:10 +00:00
implementation.go internal/lsp: remove view.FindPosInPackage and view.FindMapperInPackage 2020-01-13 18:51:11 +00:00
link.go internal/lsp/cache: add file contents to ParseGoHandle 2020-02-13 05:05:14 +00:00
lsp_test.go internal/lsp/source: make matchers selectable in WorkspaceSymbols 2020-02-13 22:46:20 +00:00
references.go internal/lsp: refactor find-references and rename 2020-01-16 06:24:15 +00:00
rename.go internal/lsp: refactor find-references and rename 2020-01-16 06:24:15 +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: change return type of PrepareRename to *Range 2020-02-13 20:00:52 +00:00
server.go internal/lsp: refactor LSP server instantiation 2020-02-06 23:12:37 +00:00
signature_help.go internal/lsp: remove unnecessary source.SignatureInformation type 2020-02-06 19:05:38 +00:00
symbols.go internal/lsp: remove view.FindPosInPackage and view.FindMapperInPackage 2020-01-13 18:51:11 +00:00
text_synchronization.go internal/lsp: don't use overlays from the session in the snapshot 2020-02-07 19:21:16 +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