tools/go
Fatih Arslan bc6db94186 go/ast/astutil: do not merge if import path is last line
DeleteNamedImport assumes the import declaration is in the form of:

    import (
      "foo"
    )

If an import path is deleted there might be a blank line-sized hole:

    import (

    )

It'll merge the black hole with the last line to change it to:

    import (
    )

However the import declaration might be in the following form as well:

    import (
      "foo")

Whic means after deleting the import path, it changes to:

    import (
    )

In this case it still tries to merge the line with a non existing line,
causing token.File.MergeLine to panic.

We fix the issue by checking that the import path line is not the last
line to avoid panicing.

Fixes golang/go#20229

Change-Id: I37537a4eaa83d14db59a2926d7bb14c27167a2e4
Reviewed-on: https://go-review.googlesource.com/44372
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-29 01:35:25 +00:00
..
ast/astutil go/ast/astutil: do not merge if import path is last line 2017-05-29 01:35:25 +00:00
buildutil x/tools/go/buildutil: remove unused function 2017-03-01 14:53:57 +00:00
callgraph tools: updates for minimum Go version 1.6 2017-02-07 21:06:19 +00:00
gccgoexportdata go/gccgoexportdata: correctly handle archive files containing string tables 2016-11-09 21:28:38 +00:00
gcexportdata go/gcexportdata: fix unnecessary plural type definitions of arg 2017-05-06 16:03:34 +00:00
gcimporter15 go/gcimporter: update to latest copy from master 2017-04-25 22:48:49 +00:00
internal/gccgoimporter x/tools/go/internal/gccgoimporter: remove unused method 2017-03-01 14:54:10 +00:00
loader go/loader: don't create types.Package for "unsafe" 2017-03-02 21:55:26 +00:00
pointer go/pointer: implement extended queries 2017-03-06 04:11:41 +00:00
ssa go/ssa/interp: fix tests on Go 1.7 and Go 1.8 2017-05-12 16:33:29 +00:00
types/typeutil tools: updates for minimum Go version 1.6 2017-02-07 21:06:19 +00:00
vcs go/vcs: allow go get on github.com/ import paths with Unicode letters 2017-04-28 05:47:26 +00:00