| 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 #ifndef TOOLS_GN_PARSE_TREE_H_ | 5 #ifndef TOOLS_GN_PARSE_TREE_H_ |
| 6 #define TOOLS_GN_PARSE_TREE_H_ | 6 #define TOOLS_GN_PARSE_TREE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 | 371 |
| 372 void set_begin_token(const Token& t) { begin_token_ = t; } | 372 void set_begin_token(const Token& t) { begin_token_ = t; } |
| 373 void set_end(scoped_ptr<EndNode> e) { end_ = e.Pass(); } | 373 void set_end(scoped_ptr<EndNode> e) { end_ = e.Pass(); } |
| 374 const EndNode* End() const { return end_.get(); } | 374 const EndNode* End() const { return end_.get(); } |
| 375 | 375 |
| 376 void append_item(scoped_ptr<ParseNode> s) { | 376 void append_item(scoped_ptr<ParseNode> s) { |
| 377 contents_.push_back(s.release()); | 377 contents_.push_back(s.release()); |
| 378 } | 378 } |
| 379 const std::vector<const ParseNode*>& contents() const { return contents_; } | 379 const std::vector<const ParseNode*>& contents() const { return contents_; } |
| 380 | 380 |
| 381 // During formatting, do we want this list to always be multliline? This is |
| 382 // used to make assignments to deps, sources, etc. always be multiline lists, |
| 383 // rather than collapsed to a single line when they're one element. |
| 384 bool prefer_multiline() const { return prefer_multiline_; } |
| 385 void set_prefer_multiline(bool prefer_multiline) { |
| 386 prefer_multiline_ = prefer_multiline; |
| 387 } |
| 388 |
| 381 private: | 389 private: |
| 382 // Tokens corresponding to the [ and ]. The end token is stored in inside an | 390 // Tokens corresponding to the [ and ]. The end token is stored in inside an |
| 383 // custom parse node so that it can have comments hung off of it. | 391 // custom parse node so that it can have comments hung off of it. |
| 384 Token begin_token_; | 392 Token begin_token_; |
| 385 scoped_ptr<EndNode> end_; | 393 scoped_ptr<EndNode> end_; |
| 394 bool prefer_multiline_; |
| 386 | 395 |
| 387 // Owning pointers, use unique_ptr when we can use C++11. | 396 // Owning pointers, use unique_ptr when we can use C++11. |
| 388 std::vector<const ParseNode*> contents_; | 397 std::vector<const ParseNode*> contents_; |
| 389 | 398 |
| 390 DISALLOW_COPY_AND_ASSIGN(ListNode); | 399 DISALLOW_COPY_AND_ASSIGN(ListNode); |
| 391 }; | 400 }; |
| 392 | 401 |
| 393 // LiteralNode ----------------------------------------------------------------- | 402 // LiteralNode ----------------------------------------------------------------- |
| 394 | 403 |
| 395 class LiteralNode : public ParseNode { | 404 class LiteralNode : public ParseNode { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 const Token& value() const { return value_; } | 505 const Token& value() const { return value_; } |
| 497 void set_value(const Token& t) { value_ = t; } | 506 void set_value(const Token& t) { value_ = t; } |
| 498 | 507 |
| 499 private: | 508 private: |
| 500 Token value_; | 509 Token value_; |
| 501 | 510 |
| 502 DISALLOW_COPY_AND_ASSIGN(EndNode); | 511 DISALLOW_COPY_AND_ASSIGN(EndNode); |
| 503 }; | 512 }; |
| 504 | 513 |
| 505 #endif // TOOLS_GN_PARSE_TREE_H_ | 514 #endif // TOOLS_GN_PARSE_TREE_H_ |
| OLD | NEW |