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

References CodeLens doesn't support methods #962

Closed
mgood opened this issue May 4, 2017 · 9 comments
Closed

References CodeLens doesn't support methods #962

mgood opened this issue May 4, 2017 · 9 comments

Comments

@mgood
Copy link

mgood commented May 4, 2017

The new references CodeLens looks really helpful, but as noted in the PR #933 it doesn't yet support methods (which all show 0 references). I think this could be fixed by adding some information in go-outline to expose the position of the identifier so I'll open another ticket there with more information.

@ramya-rao-a
Copy link
Contributor

The go/parser is used by go-outline to parse the file and get position, and for some reason for structs, the position comes back as expected, but for functions they dont.

If you can take a look at the code there (it is pretty simple) and figure that out, it would be great!

If not, then we can use regex from our side and figure out the right position before creating the codelens

mgood pushed a commit to mgood/go-outline that referenced this issue May 4, 2017
In order to support microsoft/vscode-go#962 this exposes the start/end range of
the identifiers for each declaration. In some case (particularly imports) the
`ast.Ident` is `nil`, so the identifier range is possibly `nil` too.
@mgood
Copy link
Author

mgood commented May 4, 2017

I've added a proof-of-concept PR for go-outline to add the ranges for the *ast.Ident associated with each declaration, which should provide the necessary information. I began looking at the code for this extension, but the API of GoDocumentSymbolProvider returns vscode.SymbolInformation[] which doesn't have a field for this added info. So it looks like it would probably require GoCodeLensProvider to call documentSymbols directly, and refactoring things a little bit to add this information. I might be able to look at that again a little later but I should probably get back to some normal work for today :)

@ramya-rao-a
Copy link
Contributor

Can you provide a link for your work on go-outline ? A repo maybe?

We should be able to re-use the range property of vscode.SymbolInformation, but I'll be in a much better state to make a statement if I can see what your go-outline returns.

I might be able to look at that again a little later but I should probably get back to some normal work for today :)

Take your time, the next release is atleast 2 or 3 weeks out :)

@mgood
Copy link
Author

mgood commented May 4, 2017

The PR is ramya-rao-a/go-outline#1 (it also shows up on this Github discussion since I referred back to this issue from the PR).

@mgood
Copy link
Author

mgood commented May 4, 2017

I'm still learning the VSCode API, but from what I could tell the SymbolInformation returned by the GoDocumentSymbolProvider is used to select the range to highlight, so that should still be the entire code block. But somewhere in the symbol provider it could also expose the identifier position in order to look up the references.

@mgood
Copy link
Author

mgood commented May 4, 2017

But yes, please let me know if you have any suggestions once you've had a change to take a look at the PR.

@ramya-rao-a
Copy link
Contributor

@mgood Your changes to go-outline changes the output and that may affect other users of the tool.

May has been a busy month for me, I wanted to spend more time understanding the parser and how it works.

So for now, to fix the current issue with the codelens, I have pushed a fix from the extension's side. See efa448f

I'll keep your PR open and circle back to it later as that is the real fix and my fix above is just a band aid on the real problem :)

@mgood
Copy link
Author

mgood commented Jun 9, 2017

Thanks for the fix here. I'll copy your comment about go-outline to that pull request to follow up.

@ramya-rao-a
Copy link
Contributor

The fix is now available in the latest update (0.6.62)

@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.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants