r221365 - Revert "clang-format: [js] Updates to Google's JavaScript style."
Daniel Jasper
djasper at google.com
Wed Nov 5 09:22:31 PST 2014
Author: djasper
Date: Wed Nov 5 11:22:31 2014
New Revision: 221365
URL: http://llvm.org/viewvc/llvm-project?rev=221365&view=rev
Log:
Revert "clang-format: [js] Updates to Google's JavaScript style."
This reverts commit eefd2eaad43c5c2b17953ae7ed1e72b28e696f7b.
Apparently, this change was a bit premature.
Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp
Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=221365&r1=221364&r2=221365&view=diff
==============================================================================
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Wed Nov 5 11:22:31 2014
@@ -677,7 +677,6 @@ unsigned ContinuationIndenter::moveState
if (Current.is(Keywords.kw_function))
State.Stack.back().JSFunctionInlined =
!Newline && Previous && Previous->Type != TT_DictLiteral &&
- Previous->Type != TT_ConditionalExpr &&
// If the unnamed function is the only parameter to another function,
// we can likely inline it and come up with a good format.
(Previous->isNot(tok::l_paren) || Previous->ParameterCount > 1);
Modified: cfe/trunk/lib/Format/Format.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=221365&r1=221364&r2=221365&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Wed Nov 5 11:22:31 2014
@@ -416,7 +416,7 @@ FormatStyle getGoogleStyle(FormatStyle::
GoogleStyle.ColumnLimit = 100;
GoogleStyle.SpaceAfterCStyleCast = true;
} else if (Language == FormatStyle::LK_JavaScript) {
- GoogleStyle.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment;
+ GoogleStyle.BreakBeforeTernaryOperators = false;
GoogleStyle.MaxEmptyLinesToKeep = 3;
GoogleStyle.SpacesInContainerLiterals = false;
GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=221365&r1=221364&r2=221365&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Nov 5 11:22:31 2014
@@ -8716,7 +8716,7 @@ TEST_F(FormatTest, UsesLanguageForBasedO
Style.Language = FormatStyle::LK_JavaScript;
Style.BreakBeforeTernaryOperators = true;
EXPECT_EQ(0, parseConfiguration("BasedOnStyle: Google", &Style).value());
- EXPECT_FALSE(Style.SpacesInContainerLiterals);
+ EXPECT_FALSE(Style.BreakBeforeTernaryOperators);
Style.BreakBeforeTernaryOperators = true;
EXPECT_EQ(0, parseConfiguration("---\n"
@@ -8725,7 +8725,7 @@ TEST_F(FormatTest, UsesLanguageForBasedO
"Language: JavaScript\n"
"IndentWidth: 76\n"
"...\n", &Style).value());
- EXPECT_FALSE(Style.SpacesInContainerLiterals);
+ EXPECT_FALSE(Style.BreakBeforeTernaryOperators);
EXPECT_EQ(76u, Style.IndentWidth);
EXPECT_EQ(FormatStyle::LK_JavaScript, Style.Language);
}
Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=221365&r1=221364&r2=221365&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Wed Nov 5 11:22:31 2014
@@ -55,27 +55,29 @@ TEST_F(FormatTestJS, UnderstandsJavaScri
verifyFormat("a != = b;");
verifyFormat("a === b;");
- verifyFormat("aaaaaaa\n === b;", getGoogleJSStyleWithColumns(10));
+ verifyFormat("aaaaaaa ===\n b;", getGoogleJSStyleWithColumns(10));
verifyFormat("a !== b;");
- verifyFormat("aaaaaaa\n !== b;", getGoogleJSStyleWithColumns(10));
- verifyFormat("if (a + b + c + d\n"
- " !== e + f + g)\n"
+ verifyFormat("aaaaaaa !==\n b;", getGoogleJSStyleWithColumns(10));
+ verifyFormat("if (a + b + c +\n"
+ " d !==\n"
+ " e + f + g)\n"
" q();",
getGoogleJSStyleWithColumns(20));
verifyFormat("a >> >= b;");
verifyFormat("a >>> b;");
- verifyFormat("aaaaaaa\n >>> b;", getGoogleJSStyleWithColumns(10));
+ verifyFormat("aaaaaaa >>>\n b;", getGoogleJSStyleWithColumns(10));
verifyFormat("a >>>= b;");
- verifyFormat("aaaaaaa\n >>>= b;", getGoogleJSStyleWithColumns(10));
- verifyFormat("if (a + b + c + d\n"
- " >>> e + f + g)\n"
+ verifyFormat("aaaaaaa >>>=\n b;", getGoogleJSStyleWithColumns(10));
+ verifyFormat("if (a + b + c +\n"
+ " d >>>\n"
+ " e + f + g)\n"
" q();",
getGoogleJSStyleWithColumns(20));
- verifyFormat("var x = aaaaaaaaaa\n"
- " ? bbbbbb\n"
- " : ccc;",
+ verifyFormat("var x = aaaaaaaaaa ?\n"
+ " bbbbbb :\n"
+ " ccc;",
getGoogleJSStyleWithColumns(20));
verifyFormat("var b = a.map((x) => x + 1);");
@@ -181,10 +183,11 @@ TEST_F(FormatTestJS, FunctionLiterals) {
" }\n"
"};");
// FIXME: The formatting here probably isn't ideal.
- EXPECT_EQ("abc = xyz ? function() {\n"
- " return 1;\n"
- " }\n"
- " : function() {\n"
+ EXPECT_EQ("abc = xyz ?\n"
+ " function() {\n"
+ " return 1;\n"
+ " } :\n"
+ " function() {\n"
" return -1;\n"
"};",
format("abc=xyz?function(){return 1;}:function(){return -1;};"));
More information about the cfe-commits
mailing list