LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // This file implements printing of AST nodes; specifically | 5 // This file implements printing of AST nodes; specifically |
6 // expressions, statements, declarations, and files. It uses | 6 // expressions, statements, declarations, and files. It uses |
7 // the print functionality implemented in printer.go. | 7 // the print functionality implemented in printer.go. |
8 | 8 |
9 package printer | 9 package printer |
10 | 10 |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 } | 301 } |
302 return | 302 return |
303 } | 303 } |
304 | 304 |
305 | 305 |
306 func identListSize(list []*ast.Ident, maxSize int) (size int) { | 306 func identListSize(list []*ast.Ident, maxSize int) (size int) { |
307 for i, x := range list { | 307 for i, x := range list { |
308 if i > 0 { | 308 if i > 0 { |
309 size += 2 // ", " | 309 size += 2 // ", " |
310 } | 310 } |
311 » » size += len(x.Value()) | 311 » » size += len(x.Name()) |
312 if size >= maxSize { | 312 if size >= maxSize { |
313 break | 313 break |
314 } | 314 } |
315 } | 315 } |
316 return | 316 return |
317 } | 317 } |
318 | 318 |
319 | 319 |
320 func (p *printer) isOneLineFieldList(list []*ast.Field) bool { | 320 func (p *printer) isOneLineFieldList(list []*ast.Field) bool { |
321 if len(list) != 1 { | 321 if len(list) != 1 { |
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1355 if prev != tok { | 1355 if prev != tok { |
1356 min = 2 | 1356 min = 2 |
1357 } | 1357 } |
1358 p.linebreak(d.Pos().Line, min, maxDeclNewlines, ignore,
false) | 1358 p.linebreak(d.Pos().Line, min, maxDeclNewlines, ignore,
false) |
1359 p.decl(d, atTop, ignoreMultiLine) | 1359 p.decl(d, atTop, ignoreMultiLine) |
1360 } | 1360 } |
1361 } | 1361 } |
1362 | 1362 |
1363 p.print(newline) | 1363 p.print(newline) |
1364 } | 1364 } |
LEFT | RIGHT |