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/cmd/gopls: signature help missing type name #31448

Closed
muirdm opened this issue Apr 12, 2019 · 5 comments
Closed

x/tools/cmd/gopls: signature help missing type name #31448

muirdm opened this issue Apr 12, 2019 · 5 comments

Comments

@muirdm
Copy link

@muirdm muirdm commented Apr 12, 2019

What version of Go are you using (go version)?

go version go1.12.1 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/muir/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/muir/projects/storenet/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/96/wknz1jg92yl623qgplk6qw2h0000gn/T/go-build770956951=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I viewed signature help for Cap in the following example code:

var buf bytes.Buffer
buf.Cap()

What did you expect to see?

I expected to see something like (*bytes.Buffer).Cap()

What did you see instead?

I saw bytes.Cap()

Below is the rpc trace:

[Trace - 4:04:41 PM] Sending notification 'textDocument/didChange'.
Params: {"textDocument":{"uri":"file:///Users/muir/scratch/go/foo.go","version":358},"contentChanges":[{"text":"package scratch\n\nimport \"bytes\"\n\nfunc main() {\n\tvar buf bytes.Buffer\n\tbuf.Cap()\n}\n"}]}


[Trace - 4:04:41 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {"uri":"file:///Users/muir/scratch/go/foo.go","diagnostics":[]}


[Trace - 4:04:41 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {"uri":"file:///Users/muir/scratch/go/foo_test.go","diagnostics":[]}


[Trace - 4:04:43 PM] Sending request 'textDocument/hover - (1190)'.
Params: {"textDocument":{"uri":"file:///Users/muir/scratch/go/foo.go"},"position":{"line":6,"character":9}}


[Error - 4:04:43 PM] send textDocument/hover#1190 no identifier found


[Trace - 4:04:43 PM] Sending request 'textDocument/signatureHelp - (1191)'.
Params: {"textDocument":{"uri":"file:///Users/muir/scratch/go/foo.go"},"position":{"line":6,"character":9}}


[Trace - 4:04:43 PM] Received response 'textDocument/signatureHelp - (1191)' in 0ms.
Params: {"signatures":[{"label":"bytes.Cap()"}],"activeSignature":0,"activeParameter":0}
@gopherbot gopherbot added this to the Unreleased milestone Apr 12, 2019
@muirdm
Copy link
Author

@muirdm muirdm commented Apr 12, 2019

If this issue isn't already on someone's radar, I'd like to try to fix it. Let me know if you think it is a good one.

@ianthehat ianthehat added the gopls label Apr 13, 2019
@ianthehat
Copy link

@ianthehat ianthehat commented Apr 13, 2019

I think this would be a great issue for a contributor to experiment with.

@muirdm
Copy link
Author

@muirdm muirdm commented Apr 13, 2019

Thanks, I will take a stab.

@muirdm
Copy link
Author

@muirdm muirdm commented Apr 16, 2019

I ended up just removing the package qualifier from the function name in the signature help. We could include the full invocant info, but I thought might make it too noisy and take the focus off the parameters.

While adding tests I came across a few other edge cases, so I did my best to address them.

@gopherbot
Copy link

@gopherbot gopherbot commented Apr 17, 2019

Change https://golang.org/cl/172439 mentions this issue: internal/lsp: various signatureHelp improvements

@golang golang locked and limited conversation to collaborators Apr 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants
You can’t perform that action at this time.