gn format: fix not indenting multiline continued correctly 061.gn is how it was formatted before, which is misleading. R=brettw@chromium.org BUG=348474 Review URL: https://codereview.chromium.org/774753004 Cr-Original-Commit-Position: refs/heads/master@{#306566} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: d83fc265629d2a24078132b260c76192f3cc68f1
diff --git a/tools/gn/command_format.cc b/tools/gn/command_format.cc index 1ce072d..0866f6f 100644 --- a/tools/gn/command_format.cc +++ b/tools/gn/command_format.cc
@@ -471,8 +471,9 @@ if (stack_.back().continuation_requires_indent) indent_column += kIndentSize * 2; - stack_.push_back( - IndentState(indent_column, false, binop->op().value() == "||")); + stack_.push_back(IndentState(indent_column, + stack_.back().continuation_requires_indent, + binop->op().value() == "||")); Printer sub_left; InitializeSub(&sub_left); sub_left.Expr(binop->left(), @@ -709,9 +710,7 @@ // Special case to make function calls of one arg taking a long list of // boolean operators not indent. bool continuation_requires_indent = - list.size() != 1 || !list[0]->AsBinaryOp() || - (list[0]->AsBinaryOp()->op().value() != "||" && - list[0]->AsBinaryOp()->op().value() != "&&"); + list.size() != 1 || !list[0]->AsBinaryOp(); // 1: Same line. Printer sub1;
diff --git a/tools/gn/command_format_unittest.cc b/tools/gn/command_format_unittest.cc index 73badce..1b1c08e 100644 --- a/tools/gn/command_format_unittest.cc +++ b/tools/gn/command_format_unittest.cc
@@ -96,3 +96,4 @@ FORMAT_TEST(058) FORMAT_TEST(059) FORMAT_TEST(060) +FORMAT_TEST(061)
diff --git a/tools/gn/format_test_data/061.gn b/tools/gn/format_test_data/061.gn new file mode 100644 index 0000000..5948037 --- /dev/null +++ b/tools/gn/format_test_data/061.gn
@@ -0,0 +1,9 @@ +action("generate_gl_bindings") { + args = [ + "--header-paths=" + rebase_path("//third_party/khronos", root_build_dir) + + ":" + rebase_path("//third_party/mesa/src/include", root_build_dir) + ":" + + rebase_path("//ui/gl", root_build_dir) + ":" + + rebase_path("//gpu", root_build_dir), + rebase_path(gl_binding_output_dir, root_build_dir), + ] +}
diff --git a/tools/gn/format_test_data/061.golden b/tools/gn/format_test_data/061.golden new file mode 100644 index 0000000..edbf43d --- /dev/null +++ b/tools/gn/format_test_data/061.golden
@@ -0,0 +1,9 @@ +action("generate_gl_bindings") { + args = [ + "--header-paths=" + rebase_path("//third_party/khronos", root_build_dir) + + ":" + rebase_path("//third_party/mesa/src/include", root_build_dir) + + ":" + rebase_path("//ui/gl", root_build_dir) + ":" + + rebase_path("//gpu", root_build_dir), + rebase_path(gl_binding_output_dir, root_build_dir), + ] +}