]> granicus.if.org Git - clang/commitdiff
clang-format: [JS] Make AllowShortFunctionsOnASingle line value "Empty"
authorDaniel Jasper <djasper@google.com>
Fri, 20 Nov 2015 16:44:28 +0000 (16:44 +0000)
committerDaniel Jasper <djasper@google.com>
Fri, 20 Nov 2015 16:44:28 +0000 (16:44 +0000)
work properly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253674 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTestJS.cpp

index 171ecc41d7844ceedc5af84338e81c2e2dae14dc..5aa4dadb551c8d26b0a8a65e077c800a397e68bd 100644 (file)
@@ -2104,6 +2104,7 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
         !Left.Children.empty())
       // Support AllowShortFunctionsOnASingleLine for JavaScript.
       return Style.AllowShortFunctionsOnASingleLine == FormatStyle::SFS_None ||
+             Style.AllowShortFunctionsOnASingleLine == FormatStyle::SFS_Empty ||
              (Left.NestingLevel == 0 && Line.Level == 0 &&
               Style.AllowShortFunctionsOnASingleLine ==
                   FormatStyle::SFS_Inline);
index 56a91442f9a352bcc16df20e79d01dcaddaa944b..d9b90ded15228fd4f9e37736f20bc7cb7bd895c0 100644 (file)
@@ -448,6 +448,12 @@ TEST_F(FormatTestJS, InliningFunctionLiterals) {
                "  }\n"
                "}",
                Style);
+
+  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
+  verifyFormat("var func = function() {\n"
+               "  return 1;\n"
+               "};",
+               Style);
 }
 
 TEST_F(FormatTestJS, MultipleFunctionLiterals) {