-
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.
gopls/internal/lsp/source: show promoted methods in hover
This change updates the logic to display the method set of the selected type so that: - it includes promoted methods; - it includes interface methods, if that would not be redundant with the syntax of the the type; - receiver variables are properly named, and have a pointer type if appropriate. Fixes golang/go#61634 Updates golang/go#56331 Change-Id: Ied9c06c36178424575012adb8fde0b1ddbd688c3 Reviewed-on: https://go-review.googlesource.com/c/tools/+/555456 Reviewed-by: Robert Findley <rfindley@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
- Loading branch information
Showing
7 changed files
with
120 additions
and
27 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
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,67 @@ | ||
This test checks the formatting of the list of accessible methods. | ||
|
||
Observe that: | ||
- interface methods that appear in the syntax are not repeated | ||
in the method set of the type; | ||
- promoted methods of structs are shown; | ||
- receiver variables are correctly named; | ||
- receiver variables have a pointer type if appropriate; | ||
- only accessible methods are shown. | ||
|
||
-- go.mod -- | ||
module testdata | ||
|
||
-- lib/lib.go -- | ||
package lib | ||
|
||
type I interface { | ||
A() | ||
b() | ||
J | ||
} | ||
|
||
type J interface { C() } | ||
|
||
type S struct { I } | ||
func (s S) A() {} | ||
func (s S) b() {} | ||
func (s *S) PA() {} | ||
func (s *S) pb() {} | ||
|
||
-- a/a.go -- | ||
package a | ||
|
||
import "testdata/lib" | ||
|
||
var _ lib.I //@hover("I", "I", I) | ||
var _ lib.J //@hover("J", "J", J) | ||
var _ lib.S //@hover("S", "S", S) | ||
|
||
-- @I -- | ||
```go | ||
type I interface { | ||
A() | ||
b() | ||
J | ||
} | ||
|
||
func (lib.J) C() | ||
``` | ||
|
||
[`lib.I` on pkg.go.dev](https://pkg.go.dev/testdata/lib#I) | ||
-- @J -- | ||
```go | ||
type J interface{ C() } | ||
``` | ||
|
||
[`lib.J` on pkg.go.dev](https://pkg.go.dev/testdata/lib#J) | ||
-- @S -- | ||
```go | ||
type S struct{ I } | ||
|
||
func (s lib.S) A() | ||
func (lib.J) C() | ||
func (s *lib.S) PA() | ||
``` | ||
|
||
[`lib.S` on pkg.go.dev](https://pkg.go.dev/testdata/lib#S) |