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: documentation not shown in completion results for fields of anonymous structs #43675

Closed
stamblerre opened this issue Jan 13, 2021 · 1 comment
Labels
Documentation FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@stamblerre
Copy link
Contributor

Repro:

func TestReverse(t *testing.T) {
	for _, c := range []struct {
		// input to the test
		in   string
		want string
	}{
		{"Hello, world", "dlrow ,olleH"},
		{"Hello, 世界", "界世 ,olleH"},
		{"", ""},
	} {
		// <complete c.in here>
	}
}

There will be no documentation for c.in.

@stamblerre stamblerre added this to the gopls/v1.0.0 milestone Jan 13, 2021
@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. Documentation labels Jan 13, 2021
@stamblerre stamblerre added this to To Do in gopls on-deck Feb 28, 2021
ShoshinNikita added a commit to ShoshinNikita/tools that referenced this issue Mar 9, 2021
There are 2 different anonymous struct declarations that require
different approaches:

1. var x struct{...}
2. x := struct{...}{}

For the first one we can use the existing solution just with a minor
update. However, it returns the wrong docs for the fields of nested
structs. To fix this we need to visit all fields recursively.

The second one is not a generic declaration. So, the simplest solution
is to use the method Snapshot.PosToField.

Fixes golang/go#43675
ShoshinNikita added a commit to ShoshinNikita/tools that referenced this issue Mar 9, 2021
There are 2 different anonymous struct declarations that require
different approaches:

1. var x struct{...}
2. x := struct{...}{}

For the first one we can use the existing solution with a minor update.
However, it returns the wrong docs for the fields of nested structs.
To fix this we need to visit all fields recursively.

The second one is not a generic declaration. So, the simplest solution
is to use the method Snapshot.PosToField.

Fixes golang/go#43675
@gopherbot
Copy link

Change https://golang.org/cl/300029 mentions this issue: internal/lsp/source: fix docs for fields of anonymous structs/interfaces

ShoshinNikita added a commit to ShoshinNikita/tools that referenced this issue Mar 25, 2021
There are 2 different anonymous struct declarations that require
different approaches:

1. var x struct{...}
2. x := struct{...}{}

For the first one we can use the existing solution with a minor update.
However, it returns the wrong docs for the fields of nested structs.
To fix this we need to visit all fields recursively.

The second one is not a generic declaration. So, the simplest solution
is to use the method Snapshot.PosToField.

Fixes golang/go#43675
gopls on-deck automation moved this from To Do to Done Mar 30, 2021
@golang golang locked and limited conversation to collaborators Mar 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants