Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Go to Definition and Codelens fails for anonymous struct members #1044

Closed
hhrutter opened this issue Jun 21, 2017 · 25 comments
Closed

Go to Definition and Codelens fails for anonymous struct members #1044

hhrutter opened this issue Jun 21, 2017 · 25 comments

Comments

@hhrutter
Copy link

I am on MacOS, VSCode Release May 2017 (version 1.13); Go 0.6.62

When using anonymous types like so jumping to the struct definition eg Configuration does not work neither do I get a codelens.

struct

@ramya-rao-a
Copy link
Contributor

For jumping to definition can you try setting go.docsTool to gogetdoc?

What do you get when you do a "Find All References" on this type?

@hhrutter
Copy link
Author

Hi,

I am already on gogetdoc.

When I do a "Find All References" I get a code lens
showing me the same containing struct with the type highlighted
to which definition I would like to be taken.

@ramya-rao-a
Copy link
Contributor

Can you share a complete sample code where I can try this?

@hhrutter
Copy link
Author

Sure.
Jumping to the definition works in this example for f1 and f2 but not
for the anonymous members of type foo and *foo.

package main

type foo struct {
	i int
}

type bar1 struct {
	foo
	f1 foo
}

type bar2 struct {
	*foo
	f2 *foo
}

func main() {}

@ramya-rao-a
Copy link
Contributor

Using your example, I am able to go to the definition of both foo and f1 in bar1

anoyn

@hhrutter
Copy link
Author

I know this works. I think there has been some misunderstanding
I want to inspect the members of a struct and be taken to each members definition.
That's why I left out the implementation of main, because it's irrelevant here.

Like when I hover over the bar1 struct I 'd like to inspect the definitions for f1 or the anonymous member foo especially in my case when they reside in different source files.
For f1 it works but not for the anonymous member of type foo one line above.

How did you make this animated gif?
I love it. I'd like to post what I mean by sending you one.

@ramya-rao-a
Copy link
Contributor

I used LICEcap for the gif. Its pretty easy

Yes, please share gif/video.

@hhrutter
Copy link
Author

There you go..
vs

@ramya-rao-a
Copy link
Contributor

I can repro when using gogetdoc but not when I set go.docsTool to godoc (which uses godef to find the definition)

cc @zmb3

@ramya-rao-a
Copy link
Contributor

@hhrutter you also mentioned that the codelens doesn't work. Can you elaborate on that as well? I see the references codelens on the structs

screen shot 2017-06-27 at 10 31 05 pm

@zmb3
Copy link
Contributor

zmb3 commented Jun 28, 2017

I'll take a look at the go to definition issue in gogetdoc. Thanks for the report!

@zmb3
Copy link
Contributor

zmb3 commented Jun 28, 2017

I can't seem to reproduce this. Docs tool is set to gogetdoc and here's what I get:

embed

@ramya-rao-a
Copy link
Contributor

@zmb3 Make sure go.useLanguageServer is set to false. That overrides the go.docsTool setting

@zmb3
Copy link
Contributor

zmb3 commented Jun 29, 2017

Got it. Thanks Ramya. I have a fix coded up, just need to clean up a few things and I'll have it out tomorrow.

@ramya-rao-a
Copy link
Contributor

Awesome, thanks @zmb3!

@hhrutter
Copy link
Author

hhrutter commented Jul 2, 2017

Excellent. So the codelens issue I mentioned is tied into all this.
The codelens is showing the doc for the embedded field but not for its type which makes
more sense as @zmb3 already figured.
I am going to check out @zmb3 's fix once its merged in and report back.
Thanks!

@zmb3
Copy link
Contributor

zmb3 commented Jul 2, 2017

@hhrutter the fix is committed. Just update with 'go get -u github.com/zmb3/gogetdoc'

@hhrutter
Copy link
Author

hhrutter commented Jul 2, 2017

💯 working. Thx @zmb3 & @ramya-rao-a

@hhrutter hhrutter closed this as completed Jul 2, 2017
@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Jul 4, 2017

@hhrutter just confirming.. When you say codelens do you mean the text you see when you hover on the field?

@hhrutter
Copy link
Author

hhrutter commented Jul 4, 2017

Exactly.
The codelens used to show field doc for embedded fields and now it correctly shows the type doc which makes much more sense.
vs

@ramya-rao-a
Copy link
Contributor

Ah! That got me confused. Codelens is the term used for something else entirely 😊

See https://code.visualstudio.com/blogs/2017/02/12/code-lens-roundup

@hhrutter
Copy link
Author

hhrutter commented Jul 4, 2017 via email

@ramya-rao-a
Copy link
Contributor

Hover info or tooltip

@hhrutter
Copy link
Author

hhrutter commented Jul 5, 2017 via email

@ramya-rao-a
Copy link
Contributor

Correct

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants