Go to file
Dmitri Shuralyov c0060eca2c go.tools/astutil: fix edge case in DeleteImport causing merging of import sections.
The issue occurs only when deleting an import that has a blank line immediately preceding,
and other imports before that.

Currently, DeleteImport assumes there's a blank line-sized hole left behind
where the import was, and always deletes it. That blank line-sized hole is there in all cases
except the above edge case.

This fix checks for that edge case, and does not remove the blank line-sized hole.

The CL also adds a previously failing test case that catches this scenario. After the change to
DeleteImport, the new test passes (along with all other tests).

Fixes golang/go#7679.

Note that there is no attempt to ensure the result *ast.File and *token.FileSet are perfectly
matching to what you would get if you printed the AST and parsed it back. This is how the
rest of the package and the current tests work (i.e., they only check that printing the AST gives
the correct output).
Changing that is very hard, if not impossible, at least not
without resorting to manipulating AST via printing, text manipulation and parsing.
This is okay for most usages, but it does create potential problems. For example,
astutil.Imports() currently only works correctly on freshly parsed AST. If that AST
is manipulated via astutil funcs, then Imports() may not always generate correct
output. However, thas is a separate issue and should be treated as such.

LGTM=bradfitz
R=golang-codereviews, gobot, adonovan, bradfitz
CC=golang-codereviews
https://golang.org/cl/92250045
2014-05-19 14:04:30 -07:00
astutil go.tools/astutil: fix edge case in DeleteImport causing merging of import sections. 2014-05-19 14:04:30 -07:00
blog go.tools/blog: strip prefix when serving static content 2013-11-08 13:28:32 +11:00
cmd go.tools/cmd/vet: clean up formatting of the package document 2014-05-19 11:34:31 -07:00
container/intsets go.tools: fix various minor issues found by go vet 2014-05-19 08:47:28 -07:00
cover go.tools/cover: split parsing code out from cmd/cover 2013-12-03 20:55:21 -08:00
dashboard go.tools/dashboard: update existing results when builder retries a commit 2014-05-19 09:51:04 -07:00
go go.tools/all: the the thes are too frequent, it's clear that that's not what we want 2014-05-19 09:48:30 -07:00
godoc go.tools: fix various minor issues found by go vet 2014-05-19 08:47:28 -07:00
imports go.tools/astutil: fix edge case in DeleteImport causing merging of import sections. 2014-05-19 14:04:30 -07:00
oracle go.tools: fix various typos 2014-05-02 14:38:08 -07:00
playground go.tools/playground/socket: require origin to set up socket handler 2014-05-05 08:42:12 -07:00
present go.tools/present: fix printf bug found by go vet 2014-05-16 14:29:34 -07:00
refactor go.tools/all: the the thes are too frequent, it's clear that that's not what we want 2014-05-19 09:48:30 -07:00
.hgignore go.tools/.hgignore: don't ignore test-generated files, clean them up. 2014-04-10 13:17:20 -04:00
AUTHORS go.empty: prototype for new subrepository 2012-01-25 14:45:13 -05:00
CONTRIBUTORS go.empty: prototype for new subrepository 2012-01-25 14:45:13 -05:00
LICENSE LICENSE: add 2012-03-17 15:20:58 +11:00
PATENTS go.empty: add PATENTS file to the subrepo. 2012-04-16 11:24:04 +10:00
README go.tools/README: minor correction. 2013-10-29 13:20:58 -04:00
codereview.cfg codereview: switch defaultcc to golang-codereviews 2013-12-20 10:54:33 -05:00

README

This subrepository holds the source for various packages and tools that support
the Go programming language.

Some of the tools, godoc and vet for example, are included in binary Go distributions.
Others, including the Go oracle and the test coverage tool, can be fetched with "go get".

Packages include a type-checker for Go and an implementation of the
Static Single Assignment form (SSA) representation for Go programs.

To submit changes to this repository, see http://golang.org/doc/contribute.html.