| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "tools/gn/command_format.h" | 5 #include "tools/gn/command_format.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <sstream> | 9 #include <sstream> |
| 10 | 10 |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 } else if (const LiteralNode* literal = root->AsLiteral()) { | 630 } else if (const LiteralNode* literal = root->AsLiteral()) { |
| 631 Print(literal->value().value()); | 631 Print(literal->value().value()); |
| 632 } else if (const UnaryOpNode* unaryop = root->AsUnaryOp()) { | 632 } else if (const UnaryOpNode* unaryop = root->AsUnaryOp()) { |
| 633 Print(unaryop->op().value()); | 633 Print(unaryop->op().value()); |
| 634 Expr(unaryop->operand(), kPrecedenceUnary, std::string()); | 634 Expr(unaryop->operand(), kPrecedenceUnary, std::string()); |
| 635 } else if (const BlockCommentNode* block_comment = root->AsBlockComment()) { | 635 } else if (const BlockCommentNode* block_comment = root->AsBlockComment()) { |
| 636 Print(block_comment->comment().value()); | 636 Print(block_comment->comment().value()); |
| 637 } else if (const EndNode* end = root->AsEnd()) { | 637 } else if (const EndNode* end = root->AsEnd()) { |
| 638 Print(end->value().value()); | 638 Print(end->value().value()); |
| 639 } else { | 639 } else { |
| 640 CHECK(false) << "Unhandled case in Expr."; | 640 // Unhandled case in Expr. |
| 641 CHECK(false); |
| 641 } | 642 } |
| 642 | 643 |
| 643 if (parenthesized) | 644 if (parenthesized) |
| 644 Print(")"); | 645 Print(")"); |
| 645 | 646 |
| 646 // Defer any end of line comment until we reach the newline. | 647 // Defer any end of line comment until we reach the newline. |
| 647 if (root->comments() && !root->comments()->suffix().empty()) { | 648 if (root->comments() && !root->comments()->suffix().empty()) { |
| 648 std::copy(root->comments()->suffix().begin(), | 649 std::copy(root->comments()->suffix().begin(), |
| 649 root->comments()->suffix().end(), | 650 root->comments()->suffix().end(), |
| 650 std::back_inserter(comments_)); | 651 std::back_inserter(comments_)); |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1074 } | 1075 } |
| 1075 printf("Wrote formatted to '%s'.\n", to_write.AsUTF8Unsafe().c_str()); | 1076 printf("Wrote formatted to '%s'.\n", to_write.AsUTF8Unsafe().c_str()); |
| 1076 } | 1077 } |
| 1077 } | 1078 } |
| 1078 } | 1079 } |
| 1079 | 1080 |
| 1080 return 0; | 1081 return 0; |
| 1081 } | 1082 } |
| 1082 | 1083 |
| 1083 } // namespace commands | 1084 } // namespace commands |
| OLD | NEW |