aboutsummaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src/golang.org/x/tools/go/ast
diff options
context:
space:
mode:
Diffstat (limited to 'Godeps/_workspace/src/golang.org/x/tools/go/ast')
-rw-r--r--Godeps/_workspace/src/golang.org/x/tools/go/ast/astutil/enclosing.go5
-rw-r--r--Godeps/_workspace/src/golang.org/x/tools/go/ast/astutil/imports.go24
2 files changed, 28 insertions, 1 deletions
diff --git a/Godeps/_workspace/src/golang.org/x/tools/go/ast/astutil/enclosing.go b/Godeps/_workspace/src/golang.org/x/tools/go/ast/astutil/enclosing.go
index 340c9e6cd..6b7052b89 100644
--- a/Godeps/_workspace/src/golang.org/x/tools/go/ast/astutil/enclosing.go
+++ b/Godeps/_workspace/src/golang.org/x/tools/go/ast/astutil/enclosing.go
@@ -509,7 +509,10 @@ func NodeDescription(n ast.Node) string {
return "fall-through statement"
}
case *ast.CallExpr:
- return "function call (or conversion)"
+ if len(n.Args) == 1 && !n.Ellipsis.IsValid() {
+ return "function call (or conversion)"
+ }
+ return "function call"
case *ast.CaseClause:
return "case clause"
case *ast.ChanType:
diff --git a/Godeps/_workspace/src/golang.org/x/tools/go/ast/astutil/imports.go b/Godeps/_workspace/src/golang.org/x/tools/go/ast/astutil/imports.go
index c2e2b58e6..a47bcfa3f 100644
--- a/Godeps/_workspace/src/golang.org/x/tools/go/ast/astutil/imports.go
+++ b/Godeps/_workspace/src/golang.org/x/tools/go/ast/astutil/imports.go
@@ -143,6 +143,30 @@ func AddNamedImport(fset *token.FileSet, f *ast.File, name, ipath string) (added
}
f.Imports = append(f.Imports, newImport)
+
+ if len(f.Decls) <= 1 {
+ return true
+ }
+
+ // Merge all the import declarations into the first one.
+ var first *ast.GenDecl
+ for i, decl := range f.Decls {
+ gen, ok := decl.(*ast.GenDecl)
+ if !ok || gen.Tok != token.IMPORT || declImports(gen, "C") {
+ continue
+ }
+ if first == nil {
+ first = gen
+ continue // Don't touch the first one.
+ }
+ // Move the imports of the other import declaration to the first one.
+ for _, spec := range gen.Specs {
+ spec.(*ast.ImportSpec).Path.ValuePos = first.Pos()
+ first.Specs = append(first.Specs, spec)
+ }
+ f.Decls = append(f.Decls[:i], f.Decls[i+1:]...)
+ }
+
return true
}