summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-11-05 17:22:31 +0000
committerDaniel Jasper <djasper@google.com>2014-11-05 17:22:31 +0000
commite551bb70a34ab3be4f0f9146b6ffc6c6dd61fcfe (patch)
tree6bc5e99921f1cb4510ab9dddbacfcb88df1ec261
parentf20091118cde5ef85d281a252846e06f748d6353 (diff)
downloadbcm5719-llvm-e551bb70a34ab3be4f0f9146b6ffc6c6dd61fcfe.tar.gz
bcm5719-llvm-e551bb70a34ab3be4f0f9146b6ffc6c6dd61fcfe.zip
Revert "clang-format: [js] Updates to Google's JavaScript style."
This reverts commit eefd2eaad43c5c2b17953ae7ed1e72b28e696f7b. Apparently, this change was a bit premature. llvm-svn: 221365
-rw-r--r--clang/lib/Format/ContinuationIndenter.cpp1
-rw-r--r--clang/lib/Format/Format.cpp2
-rw-r--r--clang/unittests/Format/FormatTest.cpp4
-rw-r--r--clang/unittests/Format/FormatTestJS.cpp33
4 files changed, 21 insertions, 19 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index adbd8a3d1d0..9e6014a6837 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -677,7 +677,6 @@ unsigned ContinuationIndenter::moveStateToNextToken(LineState &State,
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);
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 1eb6d97fc5c..8e4be3e053d 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -416,7 +416,7 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language) {
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;
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index b94d0f5f98a..9d62fbe14fa 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -8716,7 +8716,7 @@ TEST_F(FormatTest, UsesLanguageForBasedOnStyle) {
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, UsesLanguageForBasedOnStyle) {
"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);
}
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index 30d7c37818c..6ee150c6624 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -55,27 +55,29 @@ TEST_F(FormatTestJS, UnderstandsJavaScriptOperators) {
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;};"));
OpenPOWER on IntegriCloud