printer: complex.golden is now fixed

This commit is contained in:
Fatih Arslan 2015-11-01 01:28:11 +03:00
parent 66daded6ac
commit 858f6116bf
3 changed files with 4 additions and 8 deletions

View File

@ -33,6 +33,8 @@ func (b ByPosition) Len() int { return len(b) }
func (b ByPosition) Swap(i, j int) { b[i], b[j] = b[j], b[i] }
func (b ByPosition) Less(i, j int) bool { return b[i].Pos().Before(b[j].Pos()) }
// collectComments comments all standalone comments which are not lead or line
// comment
func (p *printer) collectComments(node ast.Node) {
// first collect all comments. This is already stored in
// ast.File.(comments)
@ -83,25 +85,21 @@ func (p *printer) collectComments(node ast.Node) {
sort.Sort(ByPosition(p.standaloneComments))
}
var count int
// output prints creates b printable HCL output and returns it.
func (p *printer) output(n interface{}) []byte {
var buf bytes.Buffer
count++
switch t := n.(type) {
case *ast.File:
return p.output(t.Node)
case *ast.ObjectList:
var index int
var nextItem token.Pos
var commented bool
for {
// TODO(arslan): refactor below comment printing, we have the same in objectType
// print stand alone upper level stand alone comments
// print upper leve stand alone comments
for _, c := range p.standaloneComments {
for _, comment := range c.List {
if index != len(t.Items) {

View File

@ -35,6 +35,7 @@ resource aws_instance "web" {
resource "aws_instance" "db" {
security_groups = "${aws_security_group.firewall.*.id}"
VPC = "foo"
depends_on = ["aws_instance.web"]
}

View File

@ -36,9 +36,6 @@ resource "aws_instance" "db" {
VPC = "foo"
depends_on = ["aws_instance.web"]
}
output "web_ip" {