diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 3df9dbf34cbf..132dd9323788 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -720,47 +720,47 @@ }, { "ImportPath": "github.com/hashicorp/hcl", - "Rev": "2604f3bda7e8960c1be1063709e7d7f0765048d0" + "Rev": "27a57f2605e04995c111273c263d51cee60d9bc4" }, { "ImportPath": "github.com/hashicorp/hcl/hcl/ast", - "Rev": "2604f3bda7e8960c1be1063709e7d7f0765048d0" + "Rev": "27a57f2605e04995c111273c263d51cee60d9bc4" }, { "ImportPath": "github.com/hashicorp/hcl/hcl/fmtcmd", - "Rev": "2604f3bda7e8960c1be1063709e7d7f0765048d0" + "Rev": "27a57f2605e04995c111273c263d51cee60d9bc4" }, { "ImportPath": "github.com/hashicorp/hcl/hcl/parser", - "Rev": "2604f3bda7e8960c1be1063709e7d7f0765048d0" + "Rev": "27a57f2605e04995c111273c263d51cee60d9bc4" }, { "ImportPath": "github.com/hashicorp/hcl/hcl/printer", - "Rev": "2604f3bda7e8960c1be1063709e7d7f0765048d0" + "Rev": "27a57f2605e04995c111273c263d51cee60d9bc4" }, { "ImportPath": "github.com/hashicorp/hcl/hcl/scanner", - "Rev": "2604f3bda7e8960c1be1063709e7d7f0765048d0" + "Rev": "27a57f2605e04995c111273c263d51cee60d9bc4" }, { "ImportPath": "github.com/hashicorp/hcl/hcl/strconv", - "Rev": "2604f3bda7e8960c1be1063709e7d7f0765048d0" + "Rev": "27a57f2605e04995c111273c263d51cee60d9bc4" }, { "ImportPath": "github.com/hashicorp/hcl/hcl/token", - "Rev": "2604f3bda7e8960c1be1063709e7d7f0765048d0" + "Rev": "27a57f2605e04995c111273c263d51cee60d9bc4" }, { "ImportPath": "github.com/hashicorp/hcl/json/parser", - "Rev": "2604f3bda7e8960c1be1063709e7d7f0765048d0" + "Rev": "27a57f2605e04995c111273c263d51cee60d9bc4" }, { "ImportPath": "github.com/hashicorp/hcl/json/scanner", - "Rev": "2604f3bda7e8960c1be1063709e7d7f0765048d0" + "Rev": "27a57f2605e04995c111273c263d51cee60d9bc4" }, { "ImportPath": "github.com/hashicorp/hcl/json/token", - "Rev": "2604f3bda7e8960c1be1063709e7d7f0765048d0" + "Rev": "27a57f2605e04995c111273c263d51cee60d9bc4" }, { "ImportPath": "github.com/hashicorp/hil", diff --git a/vendor/github.com/hashicorp/hcl/hcl/printer/nodes.go b/vendor/github.com/hashicorp/hcl/hcl/printer/nodes.go index a98495c7629d..218b56a81851 100644 --- a/vendor/github.com/hashicorp/hcl/hcl/printer/nodes.go +++ b/vendor/github.com/hashicorp/hcl/hcl/printer/nodes.go @@ -221,12 +221,12 @@ func (p *printer) objectType(o *ast.ObjectType) []byte { defer un(trace(p, "ObjectType")) var buf bytes.Buffer buf.WriteString("{") - buf.WriteByte(newline) var index int var nextItem token.Pos - var commented bool + var commented, newlinePrinted bool for { + // Print stand alone comments for _, c := range p.standaloneComments { for _, comment := range c.List { @@ -238,6 +238,13 @@ func (p *printer) objectType(o *ast.ObjectType) []byte { } if comment.Pos().After(p.prev) && comment.Pos().Before(nextItem) { + // If there are standalone comments and the initial newline has not + // been printed yet, do it now. + if !newlinePrinted { + newlinePrinted = true + buf.WriteByte(newline) + } + // add newline if it's between other printed nodes if index > 0 { commented = true @@ -258,6 +265,14 @@ func (p *printer) objectType(o *ast.ObjectType) []byte { break } + // At this point we are sure that it's not a totally empty block: print + // the initial newline if it hasn't been printed yet by the previous + // block about standalone comments. + if !newlinePrinted { + buf.WriteByte(newline) + newlinePrinted = true + } + // check if we have adjacent one liner items. If yes we'll going to align // the comments. var aligned []*ast.ObjectItem diff --git a/vendor/github.com/hashicorp/hcl/hcl/printer/printer.go b/vendor/github.com/hashicorp/hcl/hcl/printer/printer.go index fb9df58d4bfe..a296fc851a8e 100644 --- a/vendor/github.com/hashicorp/hcl/hcl/printer/printer.go +++ b/vendor/github.com/hashicorp/hcl/hcl/printer/printer.go @@ -60,5 +60,8 @@ func Format(src []byte) ([]byte, error) { return nil, err } + // Add trailing newline to result + buf.WriteString("\n") + return buf.Bytes(), nil }