-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Description
gopls version
head
go env
N/AWhat did you do?
Execute type definition
What did you see happen?
When the request location is pointing a function,
func() (foo, bar, error) gopls return "no type definition"
func() (foo, error) gopls return location to foo
func() (error) gopls return "no type definition"
#38589 mentions, gopls will ignore the error return value. The typeToObject function also only return one typeName even if multiples could be available.
What did you expect to see?
func() (foo, bar, error) gopls return locations to "foo", "bar", "error"
func() (foo, error) gopls return location to "foo", "error"
func() (error) gopls return "error"
the user can choose which type he/she want to jump to. The LSP type def support return []location.
Editor and settings
While introducing the range into TextDocumentPositionParam, I noticed that the type def method also extends TextDocumentPositionParam. So it is very intuitive idea to return type definition of an expression.
time.Now().Add(time.Second).String()
User can select a sub expression in the expression above and query "TypeDef". Some expression have multiple return values so the return type of a given expression is "types.Tuple". I wonder if it is possible to return the slice of location when the expression evaluates to a tuple.
Is there any reason for return only one location. (I understand if the language server only return one location, the language client will simply take user directly to the location without asking user "where you want to go among all these X types?")
Logs
No response