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: be more careful when computing edits or positions on fixed source #58120

Open
findleyr opened this issue Jan 27, 2023 · 0 comments
Labels
gopls/corruption Issues related to file corruption in gopls gopls/parsing Issues related to parsing / poor parser recovery. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@findleyr
Copy link
Contributor

There are a few places where gopls pre-processes source code to improve parsing (cache.fixSrc).

Surprisingly, this isn't taken into account in many places where it should be: wherever we compute positions or edits based on fixed syntax. I suspect that it isn't (usually) an issue in practice because the source fixups are limited in scope, and people don't generally try to work on source code with parse errors. Nevertheless, we should fix this. One straightforward solution may be to express the source fixes as edits, and use them to invert positions computed from the resulting parsed syntax. We'd need to remove all token.Pos helper methods from protocol.Mapper, and lift them to source.ParsedGoFile, where they can be interpreted correctly.

CC @adonovan

@findleyr findleyr added gopls/parsing Issues related to parsing / poor parser recovery. gopls/corruption Issues related to file corruption in gopls labels Jan 27, 2023
@findleyr findleyr added this to the gopls/v0.13.0 milestone Jan 27, 2023
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls/corruption Issues related to file corruption in gopls gopls/parsing Issues related to parsing / poor parser recovery. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants