-
Notifications
You must be signed in to change notification settings - Fork 18k
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: signature help does not properly qualify types #38591
Comments
Duplicate of #38230 |
This has the same root cause as the above issue, and it will be fixed by https://golang.org/cl/229319/. |
Apologies. Thanks for linking. |
I see that #38230 has now been closed, which fixes part of the problem raised in this issue. Specifically it now correctly qualifies the parameter so the label appears as:
But this still leaves the question about the return value not being qualified. |
This is doable, but I wonder if it may be bad UX. Of course the test case I came up with is pathological, but it was basically this: -- testy/testy.go --
package testy
import (
"golang.org/x/tools/internal/lsp/snippets"
)
func _() {
snippets.X()
}
-- snippets/snippets.go --
package snippets
import (
"golang.org/x/tools/internal/lsp/signature"
"golang.org/x/tools/internal/lsp/types"
)
func X(_ map[signature.Alias]types.CoolAlias) map[signatures.Alias]types.CoolAlias) {
return nil
} Then, the signature help for X is I'd be curious to get @heschik's thoughts on this. A note on how to do implement this: We'd have to check package names for any |
I definitely share this concern. But whenever you come across a situation like this it's always jarring if the package is not imported by the current file. |
IMO, if there's a problem here fully qualifying the path is not the right solution. If you're familiar with the API, the full path is just going to be an impediment to readability. If you're not, then the full path is not going to be enough to teach you how to use it. What is the actual use case? |
Change https://golang.org/cl/229979 mentions this issue: |
Just mailed a CL that handles a few edge cases, but I agree that the use case is not clearly defined. I think that we should leave this as-is for now, and if this is something that many users bring up, we can address it then. I'm not sure that the benefits of being more precise outweigh the readability costs here. |
There were a few cases where we were not properly qualifying package names, particularly if the original package had a named import. Now, we map between these names correctly - handling the case of multiple packages that need to be qualified. This requires applying edits to *ast.SelectorExprs, as well as *ast.Idents. We still do not fully qualify unimported packages, and likely won't, unless that's an issue for many users. Updates golang/go#38591 Change-Id: I966a4d1f936f37ede89362d03da3ff98d8952a06 Reviewed-on: https://go-review.googlesource.com/c/tools/+/229979 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
Closing this since the edge cases have been handled, and we're planning to leave unimported package paths as-is. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Consider the following example:
If we request signature help between the parentheses of the call expression
load.Instances()
then we get the following back:To my mind the
c
parameter's type should be qualified as*load.Config
.And strictly speaking I think the return type should be fully qualified because we do not have
cuelang.org/go/build
imported in the current file, so that type is potentially ambiguous.What did you expect to see?
A label of:
What did you see instead?
As above.
cc @stamblerre
FYI @leitzler
The text was updated successfully, but these errors were encountered: