Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: tools/gn/command_format.cc

Issue 2219083002: Update GN toolchain_args to be a variable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge remote-tracking branch 'origin/master' into toolchain_args Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/gn/args.cc ('k') | tools/gn/command_format_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 parenthesized = true; 500 parenthesized = true;
501 } else { 501 } else {
502 AddParen(prec_left, outer_prec, &parenthesized); 502 AddParen(prec_left, outer_prec, &parenthesized);
503 } 503 }
504 504
505 int start_line = CurrentLine(); 505 int start_line = CurrentLine();
506 int start_column = CurrentColumn(); 506 int start_column = CurrentColumn();
507 bool is_assignment = binop->op().value() == "=" || 507 bool is_assignment = binop->op().value() == "=" ||
508 binop->op().value() == "+=" || 508 binop->op().value() == "+=" ||
509 binop->op().value() == "-="; 509 binop->op().value() == "-=";
510 // A sort of funny special case for the long lists that are common in .gn 510
511 // files, don't indent them + 4, even though they're just continuations when 511 int indent_column = start_column;
512 // they're simple lists like "x = [ a, b, c, ... ]" 512 if (is_assignment) {
513 const ListNode* right_as_list = binop->right()->AsList(); 513 // Default to a double-indent for wrapped assignments.
514 int indent_column = 514 indent_column = margin() + kIndentSize * 2;
515 (is_assignment && 515
516 (!right_as_list || (!right_as_list->prefer_multiline() && 516 // A special case for the long lists and scope assignments that are
517 !ListWillBeMultiline(right_as_list->contents(), 517 // common in .gn files, don't indent them + 4, even though they're just
518 right_as_list->End())))) 518 // continuations when they're simple lists like "x = [ a, b, c, ... ]" or
519 ? margin() + kIndentSize * 2 519 // scopes like "x = { a = 1 b = 2 }". Put back to "normal" indenting.
520 : start_column; 520 const ListNode* right_as_list = binop->right()->AsList();
521 if (right_as_list) {
522 if (right_as_list->prefer_multiline() ||
523 ListWillBeMultiline(right_as_list->contents(),
524 right_as_list->End()))
525 indent_column = start_column;
526 } else {
527 const BlockNode* right_as_block = binop->right()->AsBlock();
528 if (right_as_block)
529 indent_column = start_column;
530 }
531 }
521 if (stack_.back().continuation_requires_indent) 532 if (stack_.back().continuation_requires_indent)
522 indent_column += kIndentSize * 2; 533 indent_column += kIndentSize * 2;
523 534
524 stack_.push_back(IndentState(indent_column, 535 stack_.push_back(IndentState(indent_column,
525 stack_.back().continuation_requires_indent, 536 stack_.back().continuation_requires_indent,
526 binop->op().value() == "||")); 537 binop->op().value() == "||"));
527 Printer sub_left; 538 Printer sub_left;
528 InitializeSub(&sub_left); 539 InitializeSub(&sub_left);
529 sub_left.Expr(binop->left(), 540 sub_left.Expr(binop->left(),
530 prec_left, 541 prec_left,
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 } 1082 }
1072 } else { 1083 } else {
1073 printf("%s", output_string.c_str()); 1084 printf("%s", output_string.c_str());
1074 } 1085 }
1075 } 1086 }
1076 1087
1077 return 0; 1088 return 0;
1078 } 1089 }
1079 1090
1080 } // namespace commands 1091 } // namespace commands
OLDNEW
« no previous file with comments | « tools/gn/args.cc ('k') | tools/gn/command_format_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698