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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/args.cc ('k') | tools/gn/command_format_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/command_format.cc
diff --git a/tools/gn/command_format.cc b/tools/gn/command_format.cc
index 7b8f2f34201f2758783e7a7e1a34816fb8be4bc0..13d8cc81e8e80b80e4517a674dee4f57799a7eb8 100644
--- a/tools/gn/command_format.cc
+++ b/tools/gn/command_format.cc
@@ -507,17 +507,28 @@ int Printer::Expr(const ParseNode* root,
bool is_assignment = binop->op().value() == "=" ||
binop->op().value() == "+=" ||
binop->op().value() == "-=";
- // A sort of funny special case for the long lists that are common in .gn
- // files, don't indent them + 4, even though they're just continuations when
- // they're simple lists like "x = [ a, b, c, ... ]"
- const ListNode* right_as_list = binop->right()->AsList();
- int indent_column =
- (is_assignment &&
- (!right_as_list || (!right_as_list->prefer_multiline() &&
- !ListWillBeMultiline(right_as_list->contents(),
- right_as_list->End()))))
- ? margin() + kIndentSize * 2
- : start_column;
+
+ int indent_column = start_column;
+ if (is_assignment) {
+ // Default to a double-indent for wrapped assignments.
+ indent_column = margin() + kIndentSize * 2;
+
+ // A special case for the long lists and scope assignments that are
+ // common in .gn files, don't indent them + 4, even though they're just
+ // continuations when they're simple lists like "x = [ a, b, c, ... ]" or
+ // scopes like "x = { a = 1 b = 2 }". Put back to "normal" indenting.
+ const ListNode* right_as_list = binop->right()->AsList();
+ if (right_as_list) {
+ if (right_as_list->prefer_multiline() ||
+ ListWillBeMultiline(right_as_list->contents(),
+ right_as_list->End()))
+ indent_column = start_column;
+ } else {
+ const BlockNode* right_as_block = binop->right()->AsBlock();
+ if (right_as_block)
+ indent_column = start_column;
+ }
+ }
if (stack_.back().continuation_requires_indent)
indent_column += kIndentSize * 2;
« 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