From 2e68ad74ea7fea8e1e2c172cb58407eacc2228eb Mon Sep 17 00:00:00 2001 From: Muir Manders Date: Tue, 17 Sep 2019 15:10:05 -0700 Subject: [PATCH] internal/lsp: fix scope of FuncType completion candidates Fix objects defined in the function signature to only be completable inside the function body. For example: func (dog Dog) bark(d<>) { // Don't complete <> to "dog". d<> // Do complete <> to "dog". } Change-Id: Ic9a2dc2ce6771212780f2d6af2221a67d203f35f Reviewed-on: https://go-review.googlesource.com/c/tools/+/196559 Run-TryBot: Rebecca Stambler TryBot-Result: Gobot Gobot Reviewed-by: Rebecca Stambler --- internal/lsp/source/completion.go | 13 +++++++++++-- internal/lsp/testdata/funcsig/func_sig.go | 9 +++++++++ internal/lsp/tests/tests.go | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 internal/lsp/testdata/funcsig/func_sig.go diff --git a/internal/lsp/source/completion.go b/internal/lsp/source/completion.go index 651c0b2b9f9..b302a18ba6a 100644 --- a/internal/lsp/source/completion.go +++ b/internal/lsp/source/completion.go @@ -563,11 +563,16 @@ func (c *completer) methodsAndFields(typ types.Type, addressable bool) error { func (c *completer) lexical() error { var scopes []*types.Scope // scopes[i], where i