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: ignore line directives #55043

Open
findleyr opened this issue Sep 13, 2022 · 1 comment
Open

x/tools/gopls: ignore line directives #55043

findleyr opened this issue Sep 13, 2022 · 1 comment
Labels
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

findleyr commented Sep 13, 2022

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 of token.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

@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 Sep 13, 2022
@gopherbot gopherbot added this to the Unreleased milestone Sep 13, 2022
@findleyr findleyr modified the milestones: Unreleased, gopls/later Sep 13, 2022
@adonovan
Copy link
Member

adonovan commented Sep 13, 2022

We could even offer an operation that jumps the cursor to the image of the current position through any applicable //line mapping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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