r256759 - clang-format: [JS] Support more ES6 default exports.
Daniel Jasper via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 4 08:10:37 PST 2016
Author: djasper
Date: Mon Jan 4 10:10:36 2016
New Revision: 256759
URL: http://llvm.org/viewvc/llvm-project?rev=256759&view=rev
Log:
clang-format: [JS] Support more ES6 default exports.
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=256759&r1=256758&r2=256759&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Jan 4 10:10:36 2016
@@ -2001,8 +2001,9 @@ bool TokenAnnotator::spaceRequiredBefore
if (Left.isOneOf(Keywords.kw_let, Keywords.kw_var, TT_JsFatArrow,
Keywords.kw_in))
return true;
- if (Left.is(tok::kw_default) && Right.is(TT_ArrayInitializerLSquare))
- return true; // For "export default [];".
+ if (Left.is(tok::kw_default) && Left.Previous &&
+ Left.Previous->is(tok::kw_export))
+ return true;
if (Left.is(Keywords.kw_is) && Right.is(tok::l_brace))
return true;
if (Right.isOneOf(TT_JsTypeColon, TT_JsTypeOptionalQuestion))
Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=256759&r1=256758&r2=256759&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Mon Jan 4 10:10:36 2016
@@ -870,6 +870,7 @@ TEST_F(FormatTestJS, Modules) {
" bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n"
"];");
verifyFormat("export default [];");
+ verifyFormat("export default () => {};");
}
TEST_F(FormatTestJS, TemplateStrings) {
More information about the cfe-commits
mailing list