| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/parse_tree.h" | 5 #include "tools/gn/parse_tree.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 return Err(value_, msg, help); | 431 return Err(value_, msg, help); |
| 432 } | 432 } |
| 433 | 433 |
| 434 void IdentifierNode::Print(std::ostream& out, int indent) const { | 434 void IdentifierNode::Print(std::ostream& out, int indent) const { |
| 435 out << IndentFor(indent) << "IDENTIFIER(" << value_.value() << ")\n"; | 435 out << IndentFor(indent) << "IDENTIFIER(" << value_.value() << ")\n"; |
| 436 PrintComments(out, indent); | 436 PrintComments(out, indent); |
| 437 } | 437 } |
| 438 | 438 |
| 439 // ListNode ------------------------------------------------------------------- | 439 // ListNode ------------------------------------------------------------------- |
| 440 | 440 |
| 441 ListNode::ListNode() { | 441 ListNode::ListNode() : prefer_multiline_(false) { |
| 442 } | 442 } |
| 443 | 443 |
| 444 ListNode::~ListNode() { | 444 ListNode::~ListNode() { |
| 445 STLDeleteContainerPointers(contents_.begin(), contents_.end()); | 445 STLDeleteContainerPointers(contents_.begin(), contents_.end()); |
| 446 } | 446 } |
| 447 | 447 |
| 448 const ListNode* ListNode::AsList() const { | 448 const ListNode* ListNode::AsList() const { |
| 449 return this; | 449 return this; |
| 450 } | 450 } |
| 451 | 451 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 474 return LocationRange(begin_token_.location(), | 474 return LocationRange(begin_token_.location(), |
| 475 end_->value().location()); | 475 end_->value().location()); |
| 476 } | 476 } |
| 477 | 477 |
| 478 Err ListNode::MakeErrorDescribing(const std::string& msg, | 478 Err ListNode::MakeErrorDescribing(const std::string& msg, |
| 479 const std::string& help) const { | 479 const std::string& help) const { |
| 480 return Err(begin_token_, msg, help); | 480 return Err(begin_token_, msg, help); |
| 481 } | 481 } |
| 482 | 482 |
| 483 void ListNode::Print(std::ostream& out, int indent) const { | 483 void ListNode::Print(std::ostream& out, int indent) const { |
| 484 out << IndentFor(indent) << "LIST\n"; | 484 out << IndentFor(indent) << "LIST" << (prefer_multiline_ ? " multiline" : "") |
| 485 << "\n"; |
| 485 PrintComments(out, indent); | 486 PrintComments(out, indent); |
| 486 for (const auto& cur : contents_) | 487 for (const auto& cur : contents_) |
| 487 cur->Print(out, indent + 1); | 488 cur->Print(out, indent + 1); |
| 488 if (end_ && end_->comments()) | 489 if (end_ && end_->comments()) |
| 489 end_->Print(out, indent + 1); | 490 end_->Print(out, indent + 1); |
| 490 } | 491 } |
| 491 | 492 |
| 492 // LiteralNode ----------------------------------------------------------------- | 493 // LiteralNode ----------------------------------------------------------------- |
| 493 | 494 |
| 494 LiteralNode::LiteralNode() { | 495 LiteralNode::LiteralNode() { |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 | 631 |
| 631 Err EndNode::MakeErrorDescribing(const std::string& msg, | 632 Err EndNode::MakeErrorDescribing(const std::string& msg, |
| 632 const std::string& help) const { | 633 const std::string& help) const { |
| 633 return Err(value_, msg, help); | 634 return Err(value_, msg, help); |
| 634 } | 635 } |
| 635 | 636 |
| 636 void EndNode::Print(std::ostream& out, int indent) const { | 637 void EndNode::Print(std::ostream& out, int indent) const { |
| 637 out << IndentFor(indent) << "END(" << value_.value() << ")\n"; | 638 out << IndentFor(indent) << "END(" << value_.value() << ")\n"; |
| 638 PrintComments(out, indent); | 639 PrintComments(out, indent); |
| 639 } | 640 } |
| OLD | NEW |