-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/lsp/source: add inferred types to generic function hover
As an experiment, this CL introduces the first gopls feature that is specific to generics: enriching function hover information with inferred types. This is done with no additional gating on build constraints by using the new internal/typeparams package. The marker tests are updated to allow tests that rely on type parameters being enabled. Change-Id: Ic627d64b61a6211389196814edd0abe1484491eb Reviewed-on: https://go-review.googlesource.com/c/tools/+/317452 Trust: Robert Findley <[email protected]> Run-TryBot: Robert Findley <[email protected]> gopls-CI: kokoro <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Rebecca Stambler <[email protected]>
- Loading branch information
Showing
10 changed files
with
239 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
-- AVariable-hover -- | ||
-- AStuff-hover -- | ||
```go | ||
var _ A | ||
func AStuff() | ||
``` | ||
|
||
variable of type a\.A | ||
-- AStuff-hover -- | ||
[`a.AStuff` on pkg.go.dev](https://pkg.go.dev/golang.org/x/tools/internal/lsp/godef/a?utm_source=gopls#AStuff) | ||
-- AVariable-hover -- | ||
```go | ||
func AStuff() | ||
var _ A | ||
``` | ||
|
||
[`a.AStuff` on pkg.go.dev](https://pkg.go.dev/golang.org/x/tools/internal/lsp/godef/a?utm_source=gopls#AStuff) | ||
variable of type a\.A |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package inferred | ||
|
||
func app[S interface{ ~[]E }, E any](s S, e E) S { | ||
return append(s, e) | ||
} | ||
|
||
func _() { | ||
_ = app[[]int] //@mark(constrInfer, "app"),hover("app", constrInfer) | ||
_ = app[[]int, int] //@mark(instance, "app"),hover("app", instance) | ||
_ = app[[]int]([]int{}, 0) //@mark(partialInfer, "app"),hover("app", partialInfer) | ||
_ = app([]int{}, 0) //@mark(argInfer, "app"),hover("app", argInfer) | ||
} |
Oops, something went wrong.