x/tools/gopls: be more careful when computing edits or positions on fixed source #58120
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
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 tosource.ParsedGoFile
, where they can be interpreted correctly.CC @adonovan
The text was updated successfully, but these errors were encountered: