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

go/token: need accessor to get to raw source position (unmodified by //line comments) #7702

Closed
griesemer opened this issue Apr 3, 2014 · 2 comments
Milestone

Comments

@griesemer
Copy link
Contributor

This is a feature request.

At the moment there's no way to obtain the raw source position from a token.Pos, that is
a position that is not modified by potential //line comments.

This leads to problems when formatting source code (gofmt, godoc) because in that case
we care about the actual source positions, not "virtual" positions. gofmt has
a work-around at the moment, and godoc does have one once issue #5247 is fixed.

See issue #5247 for more details and possible token.Pos solutions.
@gopherbot
Copy link

Comment 1:

CL https://golang.org/cl/135110044 mentions this issue.

@griesemer
Copy link
Contributor Author

Comment 2:

This issue was closed by revision e66ff2b.

Status changed to Fixed.

@griesemer griesemer self-assigned this Aug 28, 2014
@rsc rsc added this to the Go1.4 milestone Apr 14, 2015
@rsc rsc removed the release-go1.4 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jun 25, 2018
Package addition.

PositionFor permits access to both, positions
adjusted by //line comments (like the Position
accessors), and unadjusted "raw" positions
unaffected by //line comments.

Raw positions are required for correct formatting
of source code via go/printer which until now had
to manually fix adjusted positions.

Fixes golang#7702.

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/135110044
wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jul 9, 2018
Package addition.

PositionFor permits access to both, positions
adjusted by //line comments (like the Position
accessors), and unadjusted "raw" positions
unaffected by //line comments.

Raw positions are required for correct formatting
of source code via go/printer which until now had
to manually fix adjusted positions.

Fixes golang#7702.

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/135110044
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants