Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: improve completions with mutli-return value functions #36540

Closed
muirdm opened this issue Jan 14, 2020 · 3 comments
Closed

x/tools/gopls: improve completions with mutli-return value functions #36540

muirdm opened this issue Jan 14, 2020 · 3 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.

Comments

@muirdm
Copy link

muirdm commented Jan 14, 2020

We should make completion handle functions that return multiple values. For example:

// uprank functions that return two values
f, err := <>

var f *os.File
var err error

// uprank functions that return (*os.File, error)
f, err = <>

myFunc := func(int, bool) {}

// uprank functions that return (int, bool)
myFunc(<>)

All cases need to continue offering the existing scalar completions.

@gopherbot gopherbot added this to the Unreleased milestone Jan 14, 2020
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Jan 14, 2020
@gopherbot
Copy link

Thank you for filing a gopls issue! Please take a look at the Troubleshooting guide, and make sure that you have provided all of the relevant information here.

@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label Jan 14, 2020
@stamblerre stamblerre modified the milestones: Unreleased, gopls unplanned Jan 14, 2020
@gopherbot
Copy link

Change https://golang.org/cl/215538 mentions this issue: internal/lsp/source: handle completing into variadic params

@gopherbot
Copy link

Change https://golang.org/cl/215537 mentions this issue: internal/lsp/source: improve completion involving multiple return values

@stamblerre stamblerre modified the milestones: gopls unplanned, gopls completion Jan 29, 2020
gopherbot pushed a commit to golang/tools that referenced this issue Feb 6, 2020
For example:

// Prefer functions that return one or two values. Previously
// we had no preference.
foo, bar := <>

// Prefer functions that return "(int)" or "(int, ??)". Previously we
// only preferred the former.
var foo int
foo, bar := <>

// Prefer functions that return "(int)" or "(int, int)". Previously we
// only preferred the former.
var foo func(int, int)
foo(<>)

In the above example, we don't handle "foo" being variadic yet.

I also took the liberty to break up matchingCandidate() into separate
functions since it was getting rather long.

Updates golang/go#36540.

Change-Id: I9140dd989dfde1ddcfcd9d2a14198045c02587f2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215537
Run-TryBot: Muir Manders <muir@mnd.rs>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
@golang golang locked and limited conversation to collaborators Feb 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants