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: Autocompletion implementation should contain comments for the interface. #65543

Closed
tttoad opened this issue Feb 6, 2024 · 3 comments
Labels
FeatureRequest gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.

Comments

@tttoad
Copy link

tttoad commented Feb 6, 2024

gopls version

Build info ---------- golang.org/x/tools/gopls v0.15.0-pre.1 golang.org/x/tools/gopls@v0.15.0-pre.1 h1:u87rDKpsE6ax0cASyD9mJW9If25TtW0IupV6vKDDevg= github.com/BurntSushi/toml@v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= github.com/google/go-cmp@v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= golang.org/x/exp/typeparams@v0.0.0-20221212164502-fae10dda9338 h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW 6Y= golang.org/x/mod@v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= golang.org/x/sync@v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= golang.org/x/telemetry@v0.0.0-20231114163143-69313e640400 h1:brbkEFfGwNGAEkykUOcryE/JiHUMMJouzE0fWWmz/QU= golang.org/x/text@v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/tools@v0.16.2-0.20240105173808-36a523fefd90 h1:3dw2Y1Aes2o83VYvSZSPc+p70AuT9zvNCTBHCvUUZrE= golang.org/x/vuln@v1.0.1 h1:KUas02EjQK5LTuIx1OylBQdKKZ9jeugs+HiqO5HormU= honnef.co/go/tools@v0.4.5 h1:YGD4H+SuIOOqsyoLOpZDWcieM28W47/zRO7f+9V3nvo= mvdan.cc/gofumpt@v0.4.0 h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM= mvdan.cc/xurls/v2@v2.4.0 h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc= go: go1.21.5

go env

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/toad/Library/Caches/go-build'
GOENV='/Users/toad/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/toad/work/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/toad/work'
GOPRIVATE=''
GOPROXY='https://goproxy.cn,direct'
GOROOT='/Users/toad/go/go1.21.5'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/toad/go/go1.21.5/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21.5'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/toad/work/demo1/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-pref
ix-map=/var/folders/g1/tgmnlrdn3vxgv08kdgh9vpkw0000gn/T/go-build2737097617=/tmp/go-build -gno-record-gcc-switch
es -fno-common'

What did you do?

Call implements actions.

var _ A = (*AA)(nil)

type A interface {
	// AAA just AAA
	AAA() string
	// BBB just BBB
	BBB() string
}

type AA struct {
	CCC string
}

What did you see happen?

var _ A = (*AA)(nil)

type A interface {
	// AAA just AAA
	AAA() string
	// BBB just BBB
	BBB() string
}

type AA struct {
	CCC string
}

// AAA implements A.
func (*AA) AAA() string {
	panic("unimplemented")
}

// BBB implements A.
func (*AA) BBB() string {
	panic("unimplemented")
}

What did you expect to see?

var _ A = (*AA)(nil)

type A interface {
	// AAA just AAA
	AAA() string
	// BBB just BBB
	BBB() string
}

type AA struct {
	CCC string
}

// AAA just AAA
func (*AA) AAA() string {
	panic("unimplemented")
}

// BBB just BBB
func (*AA) BBB() string {
	panic("unimplemented")
}

Editor and settings

If this feature request is passed, I can provide the code to implement it.

Logs

No response

@tttoad tttoad added gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. labels Feb 6, 2024
@gopherbot gopherbot added this to the Unreleased milestone Feb 6, 2024
@tttoad tttoad changed the title x/tools/gopls: issue title x/tools/gopls: Autocompletion implementation should contain comments for the interface. Feb 6, 2024
@tttoad
Copy link
Author

tttoad commented Feb 6, 2024

@gopherbot, please add label FeatureRequest

@findleyr
Copy link
Contributor

findleyr commented Feb 7, 2024

CC @adonovan @suzmue

I think we've had several iterations of this -- people have different opinions about how to document concrete methods implementing an interface.

I'm inclined to think that the current implementation is best, since it doesn't duplicate comments, and is simple and easy to understand. The comments are also short and easy to replace or extend. For example, it is common to say "Foo implements Bar by ...".

I think duplicating the comments is more opinionated, and more likely not to be the desired behavior.

@findleyr findleyr modified the milestones: Unreleased, gopls/unplanned Feb 7, 2024
@tttoad
Copy link
Author

tttoad commented Feb 7, 2024

@findleyr Sorry for the question. I forgot this was talked about... I think I made a spelling error in my search and didn't find the previous issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest 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