r256154 - clang-format: [JS] Change Google-style default for aligning operands.
Daniel Jasper via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 21 05:52:19 PST 2015
Author: djasper
Date: Mon Dec 21 07:52:19 2015
New Revision: 256154
URL: http://llvm.org/viewvc/llvm-project?rev=256154&view=rev
Log:
clang-format: [JS] Change Google-style default for aligning operands.
The style guide allows both, but apparently, this is the more dominant use.
Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp
Modified: cfe/trunk/lib/Format/Format.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=256154&r1=256153&r2=256154&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Mon Dec 21 07:52:19 2015
@@ -578,6 +578,7 @@ FormatStyle getGoogleStyle(FormatStyle::
GoogleStyle.SpacesBeforeTrailingComments = 1;
} else if (Language == FormatStyle::LK_JavaScript) {
GoogleStyle.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+ GoogleStyle.AlignOperands = false;
GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;
GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
GoogleStyle.BreakBeforeTernaryOperators = false;
Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=256154&r1=256153&r2=256154&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Mon Dec 21 07:52:19 2015
@@ -80,8 +80,8 @@ TEST_F(FormatTestJS, UnderstandsJavaScri
" q();",
getGoogleJSStyleWithColumns(20));
verifyFormat("var x = aaaaaaaaaa ?\n"
- " bbbbbb :\n"
- " ccc;",
+ " bbbbbb :\n"
+ " ccc;",
getGoogleJSStyleWithColumns(20));
verifyFormat("var b = a.map((x) => x + 1);");
@@ -530,11 +530,11 @@ TEST_F(FormatTestJS, ArrowFunctions) {
"};");
verifyFormat("var a = a.aaaaaaa(\n"
" (a: a) => aaaaaaaaaaaaaaaaaaaaaaaaa(bbbbbbbbb) &&\n"
- " aaaaaaaaaaaaaaaaaaaaaaaaa(bbbbbbb));");
+ " aaaaaaaaaaaaaaaaaaaaaaaaa(bbbbbbb));");
verifyFormat("var a = a.aaaaaaa(\n"
" (a: a) => aaaaaaaaaaaaaaaaaaaaa(bbbbbbbbb) ?\n"
- " aaaaaaaaaaaaaaaaaaaaa(bbbbbbb) :\n"
- " aaaaaaaaaaaaaaaaaaaaa(bbbbbbb));");
+ " aaaaaaaaaaaaaaaaaaaaa(bbbbbbb) :\n"
+ " aaaaaaaaaaaaaaaaaaaaa(bbbbbbb));");
// FIXME: This is bad, we should be wrapping before "() => {".
verifyFormat("someFunction(() => {\n"
@@ -589,7 +589,7 @@ TEST_F(FormatTestJS, TryCatch) {
TEST_F(FormatTestJS, StringLiteralConcatenation) {
verifyFormat("var literal = 'hello ' +\n"
- " 'world';");
+ " 'world';");
}
TEST_F(FormatTestJS, RegexLiteralClassification) {
@@ -859,7 +859,7 @@ TEST_F(FormatTestJS, TemplateStrings) {
getGoogleJSStyleWithColumns(35)); // Barely fits.
EXPECT_EQ("var x = `hello\n"
" ${world}` >=\n"
- " some();",
+ " some();",
format("var x =\n"
" `hello\n"
" ${world}` >= some();",
@@ -884,7 +884,7 @@ TEST_F(FormatTestJS, TemplateStrings) {
// are first token in line.
verifyFormat(
"var a = aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||\n"
- " `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`;");
+ " `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`;");
// Two template strings.
verifyFormat("var x = `hello` == `hello`;");
More information about the cfe-commits
mailing list