x/tools/gopls: ignore line directives #55043
Labels
FrozenDueToAge
gopls
Issues related to the Go language server, gopls.
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
Uh oh!
There was an error while loading. Please reload this page.
From a discussion with @pjweinb and @adonovan:
The existence of line directives causes gopls all sorts of problems, because it means that there are two potentially valid source positions for a token.Pos, and it's not always clear which is correct in context. It also means that we need to access multiple files from operations that would otherwise be local to a single file. This has been a source of historical (and in all likelihood ongoing) bugs.
This issue records an outcome from that discussion: we should ignore line directives internally to gopls (in particular, being careful to call
token.File.PositionFor
instead oftoken.File.Position
). If this causes usability issues in e.g. CGo programs, we should address those issues individually. For example, we could perform a post-processing pass on diagnostics that duplicates them to their mapped positions.CC @golang/tools-team
The text was updated successfully, but these errors were encountered: