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

Inconsistent codeLens vs find references #988

Closed
IzakMarais opened this issue May 11, 2017 · 5 comments
Closed

Inconsistent codeLens vs find references #988

IzakMarais opened this issue May 11, 2017 · 5 comments

Comments

@IzakMarais
Copy link

With the following directory structure, I get inconsistent results between VSCodes CodeLens references and VSCode Find References (or running guru from the command line):

src/example/main.go:

package main

import "example2"

func main() {
	_ = example2.Long.Method()    // external references to Method() missed by codeLens
	k := example2.NewKind("test") // (creates missed reference to Kind?)
	_ = k.Method()
	k2 := example2.Kind{"test2"}
	_ = k2.Method()
}

src/example2/example2.go:

package example2

// 0 references <- Wrong
func (k Kind) Method() *string {
	str := "example2"
	return &str
}
// 5 references <- Wrong? (misses k from main.go?)
type Kind struct {
	Param string
}

var (
	Long = Kind{"puttups"}
)

// 1 reference <- Wrong
func NewKind(s string) Kind { return Kind{s} }

Screenshots of the inconsistencies. Notice how the codeLens and find references values differ.
image

image

image

Finally (this is more a guru question than a VSCode question), is it expected for guru to miss the references to the Kind struct created via NewKind()? Or is this not considered a 'referene to Kind'? E.g. is k not a reference to type Kind?

@IzakMarais
Copy link
Author

Also, is there an easy way to use VSCode to determine the byte offset of a symbol? It would help to debug issues like this using the command line tools. I'm counting number of characters from the start of the file by hand.

@IzakMarais
Copy link
Author

This looks like a duplicate of #977 and #962 . Perhaps the minimal example will help reproduce it #977 ? I'm on Windows.

@ramya-rao-a
Copy link
Contributor

Thanks for reporting this @IzakMarais and sorry for not getting back to you sooner.

I observed similar mismatch early on too. See #726 (comment)

Somehow references from outside the current workspace are getting included in the codelens.
Is that your case as well?

Funny enough both the codelens and the "Find all References" features use the same guru tool. So its weird that they find different counts.

This needs some investigation.

@theSoenke can you take a look at this?

@IzakMarais
Copy link
Author

Somehow references from outside the current workspace are getting included in the codelens.
Is that your case as well?

No, as the screenshots demonstrate, codelens shows fewer references than find all references, not more.

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Jun 1, 2017

Your first case of 0 references is being tracked in #962

In your second case, if you click on the codelens, you will see 5 references. k2 from main.go is being counted. What is not being counted is the definition of Kind. When you do a "Find all references", the definition is also counted, where as the definition is not counted in the codelens

That is by design in VS Code

The third case is same as the second.

As for the byte offset question, I am not aware of any way myself, but yes, that would indeed be very handy.

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

No branches or pull requests

2 participants