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 <sstream> | 5 #include <sstream> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
10 #include "tools/gn/commands.h" | 10 #include "tools/gn/commands.h" |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 return n > 2 && output_[n - 1] == '\n' && output_[n - 2] == '\n'; | 292 return n > 2 && output_[n - 1] == '\n' && output_[n - 2] == '\n'; |
293 } | 293 } |
294 | 294 |
295 void Printer::AnnotatePreferredMultilineAssignment(const BinaryOpNode* binop) { | 295 void Printer::AnnotatePreferredMultilineAssignment(const BinaryOpNode* binop) { |
296 const IdentifierNode* ident = binop->left()->AsIdentifier(); | 296 const IdentifierNode* ident = binop->left()->AsIdentifier(); |
297 const ListNode* list = binop->right()->AsList(); | 297 const ListNode* list = binop->right()->AsList(); |
298 // This is somewhat arbitrary, but we include the 'deps'- and 'sources'-like | 298 // This is somewhat arbitrary, but we include the 'deps'- and 'sources'-like |
299 // things, but not flags things. | 299 // things, but not flags things. |
300 if (binop->op().value() == "=" && ident && list) { | 300 if (binop->op().value() == "=" && ident && list) { |
301 const base::StringPiece lhs = ident->value().value(); | 301 const base::StringPiece lhs = ident->value().value(); |
302 if (lhs == "data" || lhs == "datadeps" || lhs == "deps" || | 302 if (lhs == "data" || lhs == "datadeps" || lhs == "data_deps" || |
303 lhs == "inputs" || lhs == "outputs" || lhs == "public" || | 303 lhs == "deps" || lhs == "inputs" || lhs == "outputs" || |
304 lhs == "public_deps" || lhs == "sources") { | 304 lhs == "public" || lhs == "public_deps" || lhs == "sources") { |
305 const_cast<ListNode*>(list)->set_prefer_multiline(true); | 305 const_cast<ListNode*>(list)->set_prefer_multiline(true); |
306 } | 306 } |
307 } | 307 } |
308 } | 308 } |
309 | 309 |
310 void Printer::SortIfSources(const BinaryOpNode* binop) { | 310 void Printer::SortIfSources(const BinaryOpNode* binop) { |
311 const IdentifierNode* ident = binop->left()->AsIdentifier(); | 311 const IdentifierNode* ident = binop->left()->AsIdentifier(); |
312 const ListNode* list = binop->right()->AsList(); | 312 const ListNode* list = binop->right()->AsList(); |
313 // TODO(scottmg): Sort more than 'sources'? | 313 // TODO(scottmg): Sort more than 'sources'? |
314 if ((binop->op().value() == "=" || binop->op().value() == "+=" || | 314 if ((binop->op().value() == "=" || binop->op().value() == "+=" || |
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1045 } | 1045 } |
1046 } else { | 1046 } else { |
1047 printf("%s", output_string.c_str()); | 1047 printf("%s", output_string.c_str()); |
1048 } | 1048 } |
1049 } | 1049 } |
1050 | 1050 |
1051 return 0; | 1051 return 0; |
1052 } | 1052 } |
1053 | 1053 |
1054 } // namespace commands | 1054 } // namespace commands |
OLD | NEW |