Skip to content

x/tools/gopls: ignore line directives #55043

Closed
@findleyr

Description

@findleyr

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

Metadata

Metadata

Labels

FrozenDueToAgeToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions