]> Cypherpunks repositories - gostls13.git/commit
go/printer: fix format with leading comments in composite literal
authorRobert Griesemer <gri@golang.org>
Wed, 25 Jan 2017 23:05:39 +0000 (15:05 -0800)
committerRobert Griesemer <gri@golang.org>
Thu, 26 Jan 2017 00:06:54 +0000 (00:06 +0000)
commit1cf08182f92698aeba8be040dafb5296707cdbf2
treef1c53924cfc2fad3bbc579bdae14d323333a2706
parentb531eb30625a28eb99f9b0137ea5a409a733a1bb
go/printer: fix format with leading comments in composite literal

This fix is less pervasive than it seems. The only change affecting
formatting is on printer.go:760. The remaining changes have no effect
on formatting since the value of p.level is ignored except on this
specific line.

The remaining changes are:
- renamed adjBlock to funcBody since that's how it is used
- introduced new printer field 'level' tracking the composite
  literal nesting level
- update/restore the composite literal nesting level as needed

Fixes #18782.

Change-Id: Ie833a9b5a559c4ec0f2eef2c5dc97aa263dca53a
Reviewed-on: https://go-review.googlesource.com/35811
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/go/printer/nodes.go
src/go/printer/printer.go
src/go/printer/testdata/comments2.golden
src/go/printer/testdata/comments2.input