Closed
Description
While solving #46136 by adding a new analyzers, stdversion, we created an internal helper package https://pkg.go.dev/golang.org/x/tools/internal/stdlib that contains a manifest of all std symbols and their versions.
We should use this information in Completions, to ensure that only version-appropriate completions are offered;
and in Hover, to report the initial Go version for each std symbol. And perhaps other places as well.
Metadata
Metadata
Assignees
Labels
Type
Projects
Relationships
Development
No branches or pull requests
Activity
adonovan commentedon May 3, 2024
On closer inspection, apparently I already added version support to completion. So that leaves just Hover.
[-]x/tools/gopls: make completion, hover use std version information[/-][+]x/tools/gopls: make Hover display std version information[/+]findleyr commentedon Jun 20, 2024
A few rough ideas for how this could be implemented:
asOfVersion string
field to hoverJSON. hoverJSON separates the data underlying hover from its presentation. The presentation format varies depending on client capabilities../gopls/internal/golang.hover
, where we have a non-nilobj
(thetypes.Object
describing the declaration), look up when the object was added to the standard library in./internal/stdlib
. Not sure exactly the best way to do this -- left as an exercise for the reader, but see existing usage ofstdlib.PackageSymbols
. In particular,Symbol.SplitField
andSymbol.SplitMethod
may be helpful for looking up fields and methods. We should perhaps have a helper to look up atypes.Object
.asOfVersion
version asgo1.X
.added in go1.X
note somewhere. pkgsite provides an example for how users are accustomed to seeing this, e.g. https://pkg.go.dev/errors#As.CC @h9jiang @hyangah
adonovan commentedon Jun 20, 2024
While we're at it, we should use the same helper in the internal doc viewer (gopls/internal/golang/pkgdoc.go). This can be a separate CL.
h9jiang commentedon Jun 21, 2024
Please assign to me to take a look. :D Thanks.
I will comment again for further questions.
gopherbot commentedon Jun 25, 2024
Change https://go.dev/cl/594875 mentions this issue:
gopls/internal/server/hover: provide available version for std lib
gopls/internal/golang: provide available version info in stdlib hover
gopherbot commentedon Jun 26, 2024
Change https://go.dev/cl/595135 mentions this issue:
gopls/internal/golang: provide version info for stdlib methods
gopls/internal/golang: provide version info for stdlib methods
gopherbot commentedon Jun 27, 2024
Change https://go.dev/cl/595336 mentions this issue:
gopls/internal/golang: provide version info for stdlib fields
gopls/internal/golang: provide version info for stdlib fields
gopherbot commentedon Jul 1, 2024
Change https://go.dev/cl/595855 mentions this issue:
gopls/internal/golang: provide version info for stdlib in pkgdoc
gopls/internal/golang: provide version info for stdlib in pkgdoc