mirror of
https://github.com/golang/go
synced 2024-11-18 13:44:48 -07:00
ae534bcb6c
This fixes a case where adding an import when there are is no existing import declaration can corrupt the position of comments attached to types. This was the last known goimports/astutil corruption case. See golang.org/issue/6884 for more details. Unfortunately this requires changing the API to add a *token.FileSet, which we should've had before. I will update goimports (the only user of this API?) immediately after submitting this. This CL also contains a hack (used only in this case of no imports): rather than fix the comment positions by hand (something that only Robert might know how to do), it instead just prints the AST, manipulates the source, and re-parses the AST. We can fix up later. Fixes golang/go#6884 R=golang-dev, gri CC=golang-dev https://golang.org/cl/38270043 |
||
---|---|---|
.. | ||
enclosing_test.go | ||
enclosing.go | ||
imports_test.go | ||
imports.go |