1
0
mirror of https://github.com/golang/go synced 2024-11-18 18:44:42 -07:00
go/internal/lsp/testdata
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
..
indirect internal/lsp/source: make matchers selectable in WorkspaceSymbols 2020-02-13 22:46:20 +00:00
lsp internal/lsp/cache: improve completion after dangling selector 2020-02-13 22:46:42 +00:00
missingdep internal/lsp/source: make matchers selectable in WorkspaceSymbols 2020-02-13 22:46:20 +00:00
missingtwodep internal/lsp/source: make matchers selectable in WorkspaceSymbols 2020-02-13 22:46:20 +00:00
unused internal/lsp/source: make matchers selectable in WorkspaceSymbols 2020-02-13 22:46:20 +00:00