OLD | NEW |
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 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 p.expr0(x.High, depth+1, multiLine) | 797 p.expr0(x.High, depth+1, multiLine) |
798 } | 798 } |
799 p.print(x.Rbrack, token.RBRACK) | 799 p.print(x.Rbrack, token.RBRACK) |
800 | 800 |
801 case *ast.CallExpr: | 801 case *ast.CallExpr: |
802 if len(x.Args) > 1 { | 802 if len(x.Args) > 1 { |
803 depth++ | 803 depth++ |
804 } | 804 } |
805 p.expr1(x.Fun, token.HighestPrec, depth, multiLine) | 805 p.expr1(x.Fun, token.HighestPrec, depth, multiLine) |
806 p.print(x.Lparen, token.LPAREN) | 806 p.print(x.Lparen, token.LPAREN) |
807 p.exprList(x.Lparen, x.Args, depth, commaSep|commaTerm, multiLin
e, x.Rparen) | |
808 if x.Ellipsis.IsValid() { | 807 if x.Ellipsis.IsValid() { |
| 808 p.exprList(x.Lparen, x.Args, depth, commaSep, multiLine,
x.Ellipsis) |
809 p.print(x.Ellipsis, token.ELLIPSIS) | 809 p.print(x.Ellipsis, token.ELLIPSIS) |
| 810 if x.Rparen.IsValid() && p.lineFor(x.Ellipsis) < p.lineF
or(x.Rparen) { |
| 811 p.print(token.COMMA, formfeed) |
| 812 } |
| 813 } else { |
| 814 p.exprList(x.Lparen, x.Args, depth, commaSep|commaTerm,
multiLine, x.Rparen) |
810 } | 815 } |
811 p.print(x.Rparen, token.RPAREN) | 816 p.print(x.Rparen, token.RPAREN) |
812 | 817 |
813 case *ast.CompositeLit: | 818 case *ast.CompositeLit: |
814 // composite literal elements that are composite literals themse
lves may have the type omitted | 819 // composite literal elements that are composite literals themse
lves may have the type omitted |
815 if x.Type != nil { | 820 if x.Type != nil { |
816 p.expr1(x.Type, token.HighestPrec, depth, multiLine) | 821 p.expr1(x.Type, token.HighestPrec, depth, multiLine) |
817 } | 822 } |
818 p.print(x.Lbrace, token.LBRACE) | 823 p.print(x.Lbrace, token.LBRACE) |
819 p.exprList(x.Lbrace, x.Elts, 1, commaSep|commaTerm, multiLine, x
.Rbrace) | 824 p.exprList(x.Lbrace, x.Elts, 1, commaSep|commaTerm, multiLine, x
.Rbrace) |
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1508 if prev != tok || getDoc(d) != nil { | 1513 if prev != tok || getDoc(d) != nil { |
1509 min = 2 | 1514 min = 2 |
1510 } | 1515 } |
1511 p.linebreak(p.lineFor(d.Pos()), min, ignore, false) | 1516 p.linebreak(p.lineFor(d.Pos()), min, ignore, false) |
1512 p.decl(d, ignoreMultiLine) | 1517 p.decl(d, ignoreMultiLine) |
1513 } | 1518 } |
1514 } | 1519 } |
1515 | 1520 |
1516 p.print(newline) | 1521 p.print(newline) |
1517 } | 1522 } |
OLD | NEW |