Author: djasper Date: Thu Mar 17 07:17:59 2016 New Revision: 263710 URL: http://llvm.org/viewvc/llvm-project?rev=263710&view=rev Log: clang-format: [JS] Fix incorrect spacing around contextual keywords.
Before: x.of (); After: x.of(); 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=263710&r1=263709&r2=263710&view=diff ============================================================================== --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original) +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Mar 17 07:17:59 2016 @@ -2038,8 +2038,11 @@ bool TokenAnnotator::spaceRequiredBefore Left.isOneOf(Keywords.kw_returns, Keywords.kw_option)) return true; } else if (Style.Language == FormatStyle::LK_JavaScript) { - if (Left.isOneOf(Keywords.kw_let, Keywords.kw_var, TT_JsFatArrow, - Keywords.kw_in, Keywords.kw_of)) + if (Left.is(TT_JsFatArrow)) + return true; + if (Left.isOneOf(Keywords.kw_let, Keywords.kw_var, Keywords.kw_in, + Keywords.kw_of) && + (!Left.Previous || !Left.Previous->is(tok::period))) return true; if (Left.is(tok::kw_default) && Left.Previous && Left.Previous->is(tok::kw_export)) Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=263710&r1=263709&r2=263710&view=diff ============================================================================== --- cfe/trunk/unittests/Format/FormatTestJS.cpp (original) +++ cfe/trunk/unittests/Format/FormatTestJS.cpp Thu Mar 17 07:17:59 2016 @@ -125,6 +125,10 @@ TEST_F(FormatTestJS, ReservedWords) { verifyFormat("x.class.struct = 1;"); verifyFormat("x.case = 1;"); verifyFormat("x.interface = 1;"); + verifyFormat("x.of() = 1;"); + verifyFormat("x.in() = 1;"); + verifyFormat("x.let() = 1;"); + verifyFormat("x.var() = 1;"); verifyFormat("x = {\n" " a: 12,\n" " interface: 1,\n" _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits