1
0
mirror of https://github.com/golang/go synced 2024-10-01 01:28:32 -06:00
go/astutil
Brad Fitzpatrick ae534bcb6c astutil: fix a comment corruption case
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
2013-12-16 14:43:29 -08:00
..
enclosing_test.go go.tools/importer: move PathEnclosingInterval to package astutil. 2013-12-09 09:36:29 -05:00
enclosing.go go.tools/oracle: improvements to command set and performance. 2013-12-13 10:04:55 -05:00
imports_test.go astutil: fix a comment corruption case 2013-12-16 14:43:29 -08:00
imports.go astutil: fix a comment corruption case 2013-12-16 14:43:29 -08:00