internal/lsp/source: filter out comparable from completion results

The comparable interface is introduced on the dev.typeparams branch.
Filter it out from gopls completion results so that it doesn't break
tests on the dev.typeparams branch.

Change-Id: Iba22c0980c09e99b454ce9e22813cc3a1f94a90c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/293931
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
Rob Findley 2021-02-18 16:26:44 -05:00 committed by Robert Findley
parent f47cb783b1
commit f3748ed8ec
1 changed files with 8 additions and 0 deletions

View File

@ -1264,6 +1264,11 @@ func (c *completer) lexical(ctx context.Context) error {
var (
builtinIota = types.Universe.Lookup("iota")
builtinNil = types.Universe.Lookup("nil")
// comparable is an interface that exists on the dev.typeparams Go branch.
// Filter it out from completion results to stabilize tests.
// TODO(rFindley) update (or remove) our handling for comparable once the
// type parameter API has stabilized.
builtinComparable = types.Universe.Lookup("comparable")
)
// Track seen variables to avoid showing completions for shadowed variables.
@ -1282,6 +1287,9 @@ func (c *completer) lexical(ctx context.Context) error {
if declScope != scope {
continue // Name was declared in some enclosing scope, or not at all.
}
if obj == builtinComparable {
continue
}
// If obj's type is invalid, find the AST node that defines the lexical block
// containing the declaration of obj. Don't resolve types for packages.