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: send back ranges for parse errors #29150

Open
stamblerre opened this issue Dec 7, 2018 · 5 comments
Assignees
Milestone

Comments

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Dec 7, 2018

We currently only send the starting position of an error in LSP diagnostics. We should determine the end of the error as well. For type errors, we can just get the length of the identifier. We will need another approach for parse errors.

@gopherbot gopherbot added this to the Unreleased milestone Dec 7, 2018
@zmb3

This comment has been minimized.

Copy link
Contributor

@zmb3 zmb3 commented Dec 18, 2018

Happy to take this one, but need some pointers on how to get to the identifier given just the token.Position from the error message. Seems we need to convert to a token.Pos, I'm not sure how to convert in that direction.

@stamblerre

This comment has been minimized.

Copy link
Contributor Author

@stamblerre stamblerre commented Dec 18, 2018

@zmb3: I saw your reply and started trying to refactor things to make it easier to fix this bug, and then I got a bit carried away and got through about 3/4 of the fix myself. Did you want to fix this yourself or is it cool if I send out my CL? My CL won't fix everything - it handles ranges for types.Errors, but not for scanner.Errors, which are a bit more complicated.

@zmb3

This comment has been minimized.

Copy link
Contributor

@zmb3 zmb3 commented Dec 18, 2018

No, please go ahead and send your CL. I’m anxious to see what you came up with 😀

@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Dec 18, 2018

Change https://golang.org/cl/154742 mentions this issue: internal/lsp: add ranges to some diagnostics messages

@stamblerre stamblerre self-assigned this Dec 19, 2018
gopherbot pushed a commit to golang/tools that referenced this issue Dec 20, 2018
Added a View interface to the source package, which allows for reading
of other files (in the same package or in other packages). We were
already reading files in jump to definition (to handle the lack of
column information in export data), but now we can also read files in
diagnostics, which allows us to determine the end of an identifier so
that we can report ranges in diagnostic messages.

Updates golang/go#29150

Change-Id: I7958d860dea8f41f2df88a467b5e2946bba4d1c5
Reviewed-on: https://go-review.googlesource.com/c/154742
Reviewed-by: Ian Cottrell <iancottrell@google.com>
@stamblerre stamblerre added gopls and removed gopls labels Mar 12, 2019
@stamblerre stamblerre changed the title x/tools/internal/lsp: send back ranges for diagnostics x/tools/internal/lsp: send back ranges for parse errors Jun 5, 2019
@stamblerre stamblerre added the Suggested label Jun 5, 2019
@stamblerre stamblerre added the NeedsFix label Jun 28, 2019
@stamblerre stamblerre changed the title x/tools/internal/lsp: send back ranges for parse errors x/tools/gopls: send back ranges for parse errors Jul 2, 2019
@stamblerre stamblerre added help wanted and removed Suggested labels Aug 8, 2019
@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Oct 21, 2019

Change https://golang.org/cl/202542 mentions this issue: internal/lsp: use the AST to get correct ranges

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.