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: gc_details codelens is broken because gopls_gc_details command is not included in initialization #41985

Closed
hyangah opened this issue Oct 14, 2020 · 2 comments
Labels
Milestone

Comments

@hyangah
Copy link
Contributor

@hyangah hyangah commented Oct 14, 2020

$ gopls -v version
Build info
----------
golang.org/x/tools/gopls master
    golang.org/x/tools/gopls@v0.0.0-20201014170642-d1624618ad65 h1:lvYvyth3KR9zDdDRWZ6Olt3KNZ5iWVWLJPojDK1Kf0A=
    github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/google/go-cmp@v0.5.1 h1:JFrFEBb2xKufg6XkJsJr+WbKb4FQlURi5RUcBveYu9k=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/mod@v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
    golang.org/x/sync@v0.0.0-20200625203802-6e8e738ad208 h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA=
    golang.org/x/tools@v0.0.0-20201014170642-d1624618ad65 h1:q80OtYaeeySe8Kqg0vjXehHwj5fUTqe3xOvnbi5w3Gg=
    golang.org/x/xerrors@v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
    honnef.co/go/tools@v0.0.1-2020.1.5 h1:nI5egYTGJakVyOryqLs1cQO5dO0ksin5XXs2pspk75k=
    mvdan.cc/gofumpt@v0.0.0-20200802201014-ab5a8192947d h1:t8TAw9WgTLghti7RYkpPmqk4JtQ3+wcP5GgZqgWeWLQ=
    mvdan.cc/xurls/v2@v2.2.0 h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A=
$ gopls api-json | jq
{
    ...
    {
      "Command": "gc_details",
      "Title": "Toggle gc_details",
      "Doc": "gc_details controls calculation of gc annotations.\n"
    },
    ...
    {
      "Lens": "gc_details",
      "Title": "Toggle gc_details",
      "Doc": "gc_details controls calculation of gc annotations.\n"
    }
 }

Initialization still lists gc_details, so gc_details command is registered to vscode.

[Trace - 19:16:24.915 PM] Received response 'initialize - (0)' in 1ms.
Result: {
...
  "executeCommandProvider":{"commands":["generate","fill_struct","regenerate_cgo","test","tidy","undeclared_name","upgrade_dependency","vendor","extract_variable","extract_function","gc_details","generate_gopls_mod"]},
...
}

CodeLens uses gopls_gc_details

[Trace - 19:12:38.210 PM] Received response 'textDocument/codeLens - (21)' in 0ms.
Result: [{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":0}},"command":{"title":"Toggle gc annotation details","command":"gopls_gc_details","arguments":["file:///Users/hakim/hello/mypkg/mypkg.go"]}}]

Since gopls_gc_details was never registered, vscode just errors.
OTOH, vscode sends gc_details command to gopls, which results in 'no known command' error.

@gopherbot gopherbot added this to the Unreleased milestone Oct 14, 2020
@hyangah hyangah modified the milestones: Unreleased, gopls/v0.5.2 Oct 14, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Oct 15, 2020

Change https://golang.org/cl/262354 mentions this issue: internal/lsp: send "gopls_" prefixed commands in initialize

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 15, 2020

Change https://golang.org/cl/262597 mentions this issue: internal/lsp/source: be consistent about command identifiers

gopherbot pushed a commit to golang/tools that referenced this issue Oct 15, 2020
The primary identifier for gopls commands was changed from Command.Name
to Command.ID(), but this change was not made in the commands passed
back to the client via ExecuteCommandOptions.

Fix this, and ensure that our regtests actually check commands against
the list of supported commands that has been sent.

For golang/go#41985

Change-Id: If566584f157e8a86d26eac6353dbfd772b298cfc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/262597
Run-TryBot: Robert Findley <rfindley@google.com>
Trust: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.