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: "no object found" when renaming a function from within its doc comment #42301

Open
bcmills opened this issue Oct 30, 2020 · 1 comment
Labels
FeatureRequest gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Refactoring Issues related to refactoring tools Tools This label describes issues relating to any tools in the x/tools repository.

Comments

@bcmills
Copy link
Contributor

bcmills commented Oct 30, 2020

example.com$ go version
go version devel +f7e26467b Fri Oct 30 01:31:10 2020 +0000 linux/amd64

example.com$ go version -m $(which gopls)
/usr/local/google/home/bcmills/bin/gopls: devel +186f0220d0 Mon Oct 5 11:12:24 2020 -0400
        path    golang.org/x/tools/gopls
        mod     golang.org/x/tools/gopls        v0.5.1  h1:AF3Uh7HF08SZpKFfgJO6zfF3bbxyDXWqdkK4kMXiQ1o=
        dep     github.com/BurntSushi/toml      v0.3.1  h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
        dep     github.com/google/go-cmp        v0.5.1  h1:JFrFEBb2xKufg6XkJsJr+WbKb4FQlURi5RUcBveYu9k=
        dep     github.com/sergi/go-diff        v1.1.0  h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
        dep     golang.org/x/mod        v0.3.0  h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
        dep     golang.org/x/sync       v0.0.0-20200625203802-6e8e738ad208      h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA=
        dep     golang.org/x/tools      v0.0.0-20200930165741-f1523d29dbb9      h1:1R38tQp22dcHpTKJPjgVa16FhlDy/kHEaCM/ndi/FIc=
        dep     golang.org/x/xerrors    v0.0.0-20200804184101-5ec99f83aff1      h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
        dep     honnef.co/go/tools      v0.0.1-2020.1.5 h1:nI5egYTGJakVyOryqLs1cQO5dO0ksin5XXs2pspk75k=
        dep     mvdan.cc/gofumpt        v0.0.0-20200802201014-ab5a8192947d      h1:t8TAw9WgTLghti7RYkpPmqk4JtQ3+wcP5GgZqgWeWLQ=
        dep     mvdan.cc/xurls/v2       v2.2.0  h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A=

What did you do?

example.go:

package example

// Foo returns a word associated with "foo".
func Foo() string {
        return "bar"
}
  1. emacs example.go
  2. Move the point to the word Foo within the comment (example.go:3:4).
  3. M-x eglot-rename
  4. Type in a new name.

What did you expect to see?

The function described in the comment should be renamed to the new name, and all known references to that function should be updated.

What did you see instead?

no object found

[Trace - 14:23:12.755 PM] Sending request 'initialize - (1)'.
Params: {"processId":1038918,"rootPath":"/tmp/tmp.nT6diPQffo/example.com/","rootUri":"file:///tmp/tmp.nT6diPQffo/example.com/","initializationOptions":null,"capabilities":{"workspace":{"applyEdit":true,"executeCommand":{"dynamicRegistration":false},"workspaceEdit":{"documentChanges":false},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":false},"configuration":true},"textDocument":{"synchronization":{"dynamicRegistration":false,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":false,"completionItem":{"snippetSupport":true},"contextSupport":true},"hover":{"dynamicRegistration":false,"contentFormat":["markdown","plaintext"]},"signatureHelp":{"dynamicRegistration":false,"signatureInformation":{"parameterInformation":{"labelOffsetSupport":true}}},"references":{"dynamicRegistration":false},"definition":{"dynamicRegistration":false},"declaration":{"dynamicRegistration":false},"implementation":{"dynamicRegistration":false},"typeDefinition":{"dynamicRegistration":false},"documentSymbol":{"dynamicRegistration":false,"hierarchicalDocumentSymbolSupport":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"documentHighlight":{"dynamicRegistration":false},"codeAction":{"dynamicRegistration":false,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"formatting":{"dynamicRegistration":false},"rangeFormatting":{"dynamicRegistration":false},"rename":{"dynamicRegistration":false},"publishDiagnostics":{"relatedInformation":false}},"experimental":null}}


[Trace - 14:23:12.757 PM] Received response 'initialize - (1)' in 1ms.
Result: {"capabilities":{"textDocumentSync":{"openClose":true,"change":2,"save":{}},"completionProvider":{"triggerCharacters":["."]},"hoverProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",","]},"definitionProvider":true,"typeDefinitionProvider":true,"implementationProvider":true,"referencesProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"codeActionProvider":{"codeActionKinds":["quickfix","refactor.extract","refactor.rewrite","source.fixAll","source.organizeImports"]},"codeLensProvider":{},"documentLinkProvider":{},"workspaceSymbolProvider":true,"documentFormattingProvider":true,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":""},"renameProvider":true,"foldingRangeProvider":true,"executeCommandProvider":{"commands":["generate","fill_struct","regenerate_cgo","test","tidy","undeclared_name","upgrade_dependency","vendor","extract_variable","extract_function","gc_details","generate_gopls_mod"]},"callHierarchyProvider":true,"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":"workspace/didChangeWorkspaceFolders"}}},"serverInfo":{"name":"gopls","version":"Build info\n----------\ngolang.org/x/tools/gopls v0.5.1\n    golang.org/x/tools/gopls@v0.5.1 h1:AF3Uh7HF08SZpKFfgJO6zfF3bbxyDXWqdkK4kMXiQ1o=\n    github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=\n    github.com/google/go-cmp@v0.5.1 h1:JFrFEBb2xKufg6XkJsJr+WbKb4FQlURi5RUcBveYu9k=\n    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=\n    golang.org/x/mod@v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=\n    golang.org/x/sync@v0.0.0-20200625203802-6e8e738ad208 h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA=\n    golang.org/x/tools@v0.0.0-20200930165741-f1523d29dbb9 h1:1R38tQp22dcHpTKJPjgVa16FhlDy/kHEaCM/ndi/FIc=\n    golang.org/x/xerrors@v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=\n    honnef.co/go/tools@v0.0.1-2020.1.5 h1:nI5egYTGJakVyOryqLs1cQO5dO0ksin5XXs2pspk75k=\n    mvdan.cc/gofumpt@v0.0.0-20200802201014-ab5a8192947d h1:t8TAw9WgTLghti7RYkpPmqk4JtQ3+wcP5GgZqgWeWLQ=\n    mvdan.cc/xurls/v2@v2.2.0 h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A=\n"}}


[Trace - 14:23:12.758 PM] Sending notification 'initialized'.
Params: {}


[Trace - 14:23:12.758 PM] Received notification 'window/showMessage'.
Params: {"type":4,"message":"Loading packages..."}


[Trace - 14:23:12.758 PM] Received request 'workspace/configuration - (1)'.
Params: {"items":[{"scopeUri":"file:///tmp/tmp.nT6diPQffo/example.com/","section":"gopls"},{"scopeUri":"file:///tmp/tmp.nT6diPQffo/example.com/","section":"gopls-example.com"}]}


[Trace - 14:23:12.759 PM] Sending notification 'textDocument/didOpen'.
Params: {"textDocument":{"uri":"file:///tmp/tmp.nT6diPQffo/example.com/example.go","version":0,"languageId":"go","text":"package example\n\n// Foo returns a word associated with \"foo\".\nfunc Foo() string {\n\treturn \"bar\"\n}\n"}}


[Trace - 14:23:12.760 PM] Sending notification 'workspace/didChangeConfiguration'.
Params: {"settings":{"gopls":{"staticcheck":true,"matcher":"CaseSensitive"}}}


[Trace - 14:23:12.760 PM] Sending request 'textDocument/documentSymbol - (2)'.
Params: {"textDocument":{"uri":"file:///tmp/tmp.nT6diPQffo/example.com/example.go"}}


[Trace - 14:23:12.765 PM] Sending response 'workspace/configuration - (1)' in 6ms.
Result: [{"staticcheck":true,"matcher":"CaseSensitive"},null]


[Trace - 14:23:12.793 PM] Received request 'client/registerCapability - (2)'.
Params: {"registrations":[{"id":"workspace/didChangeWatchedFiles-0","method":"workspace/didChangeWatchedFiles","registerOptions":{"watchers":[{"globPattern":"**/*.{go,mod,sum}","kind":7},{"globPattern":"/tmp/tmp.nT6diPQffo/example.com/**/*.{go,mod,sum}","kind":7}]}}]}


[Trace - 14:23:12.793 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/10/30 14:23:12 go env for /tmp/tmp.nT6diPQffo/example.com/\n(root /tmp/tmp.nT6diPQffo/example.com)\n(go version go version devel +f7e26467b Fri Oct 30 01:31:10 2020 +0000 linux/amd64\n)\n(valid build configuration = true)\n(build flags: [])\nGOPATH=/tmp/tmp.nT6diPQffo/_gopath\nGOPRIVATE=\nGOPROXY=https://proxy.golang.org,direct\nGO111MODULE=auto\nGOMOD=/tmp/tmp.nT6diPQffo/example.com/go.mod\nGOSUMDB=sum.golang.org\nGOINSECURE=\nGONOSUMDB=\nGOROOT=/usr/local/google/home/bcmills/sdk/gotip\nGOCACHE=/usr/local/google/home/bcmills/.cache/go-build\nGOMODCACHE=/tmp/tmp.nT6diPQffo/_gopath/pkg/mod\nGOFLAGS=\nGONOPROXY=\n\n"}


[Trace - 14:23:12.794 PM] Sending response 'client/registerCapability - (2)' in 1ms.
Result: 


[Trace - 14:23:12.887 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/10/30 14:23:12 go/packages.Load\n\tsnapshot=0\n\tdirectory=/tmp/tmp.nT6diPQffo/example.com\n\tquery=[./... builtin]\n\tpackages=2\n"}


[Trace - 14:23:12.887 PM] Received notification 'window/showMessage'.
Params: {"type":3,"message":"Finished loading packages."}


[Trace - 14:23:12.888 PM] Received request 'workspace/configuration - (3)'.
Params: {"items":[{"scopeUri":"file:///tmp/tmp.nT6diPQffo/example.com/","section":"gopls"},{"scopeUri":"file:///tmp/tmp.nT6diPQffo/example.com/","section":"gopls-example.com"}]}


[Trace - 14:23:12.905 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {"uri":"file:///tmp/tmp.nT6diPQffo/example.com/example.go","diagnostics":[{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":15}},"severity":2,"source":"ST1000","message":"at least one file in a package should have a package comment"}]}


[Trace - 14:23:12.910 PM] Sending response 'workspace/configuration - (3)' in 22ms.
Result: [{"staticcheck":true,"matcher":"CaseSensitive"},null]


[Trace - 14:23:12.911 PM] Received response 'textDocument/documentSymbol - (2)' in 150ms.
Result: [{"name":"Foo","detail":"()","kind":12,"range":{"start":{"line":3,"character":0},"end":{"line":5,"character":1}},"selectionRange":{"start":{"line":3,"character":5},"end":{"line":3,"character":8}}}]


[Trace - 14:23:30.744 PM] Sending request 'textDocument/signatureHelp - (3)'.
Params: {"textDocument":{"uri":"file:///tmp/tmp.nT6diPQffo/example.com/example.go"},"position":{"line":2,"character":3}}


[Trace - 14:23:30.745 PM] Received response 'textDocument/signatureHelp - (3)' in 0ms.
Result: null


[Trace - 14:23:30.745 PM] Sending request 'textDocument/hover - (4)'.
Params: {"textDocument":{"uri":"file:///tmp/tmp.nT6diPQffo/example.com/example.go"},"position":{"line":2,"character":3}}


[Trace - 14:23:30.746 PM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"2020/10/30 14:23:30 no signature help: cannot find an enclosing function\n\tposition={2 3}\n"}


[Trace - 14:23:30.746 PM] Received response 'textDocument/hover - (4)' in 0ms.
Result: null


[Trace - 14:23:30.747 PM] Sending request 'textDocument/documentHighlight - (5)'.
Params: {"textDocument":{"uri":"file:///tmp/tmp.nT6diPQffo/example.com/example.go"},"position":{"line":2,"character":3}}


[Trace - 14:23:30.747 PM] Received response 'textDocument/documentHighlight - (5)' in 0ms.
Result: []


[Trace - 14:23:37.443 PM] Sending request 'textDocument/rename - (6)'.
Params: {"textDocument":{"uri":"file:///tmp/tmp.nT6diPQffo/example.com/example.go"},"position":{"line":2,"character":3},"newName":"Baz"}


[Error - Received] 14:23:37.444 PM #6 no object found


@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Oct 30, 2020
@gopherbot gopherbot added this to the Unreleased milestone Oct 30, 2020
@bcmills bcmills added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. and removed Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Oct 30, 2020
@stamblerre stamblerre modified the milestones: Unreleased, gopls/unplanned Nov 2, 2020
@jeanbza
Copy link
Member

jeanbza commented Jun 25, 2021

Just as an extra data point: using vscode and rename symbol on the same code, I don't see an error, I see:


[Trace - 08:38:09.405 AM] Sending request 'textDocument/prepareRename - (103)'.
Params: {"textDocument":{"uri":"file:///tmp/tmp.unYU5bH8B4/example.go"},"position":{"line":2,"character":3}}


[Trace - 08:38:09.405 AM] Received response 'textDocument/prepareRename - (103)' in 0ms.
Result: null


[Trace - 08:38:09.655 AM] Sending request 'textDocument/codeLens - (104)'.
Params: {"textDocument":{"uri":"file:///tmp/tmp.unYU5bH8B4/example.go"}}


[Trace - 08:38:09.655 AM] Received response 'textDocument/codeLens - (104)' in 0ms.
Result: null

And, a popup that says, "The element can't be renamed.".

@adonovan adonovan added the Refactoring Issues related to refactoring tools label Apr 24, 2023
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. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Refactoring Issues related to refactoring tools Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

6 participants