r285672 - clang-format: [JS] Fix incorrect space when "as" is used as identifier.
Daniel Jasper via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 31 23:23:10 PDT 2016
Author: djasper
Date: Tue Nov 1 01:23:10 2016
New Revision: 285672
URL: http://llvm.org/viewvc/llvm-project?rev=285672&view=rev
Log:
clang-format: [JS] Fix incorrect space when "as" is used as identifier.
Before:
aaaaa.as ();
After:
aaaaa.as();
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=285672&r1=285671&r2=285672&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Nov 1 01:23:10 2016
@@ -2160,7 +2160,7 @@ bool TokenAnnotator::spaceRequiredBefore
Keywords.kw_of, tok::kw_const) &&
(!Left.Previous || !Left.Previous->is(tok::period)))
return true;
- if (Left.is(tok::kw_for) && Left.Previous &&
+ if (Left.isOneOf(tok::kw_for, Keywords.kw_as) && Left.Previous &&
Left.Previous->is(tok::period) && Right.is(tok::l_paren))
return false;
if (Left.is(Keywords.kw_as) &&
Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=285672&r1=285671&r2=285672&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue Nov 1 01:23:10 2016
@@ -136,6 +136,7 @@ TEST_F(FormatTestJS, ReservedWords) {
verifyFormat("x.let() = 1;");
verifyFormat("x.var() = 1;");
verifyFormat("x.for() = 1;");
+ verifyFormat("x.as() = 1;");
verifyFormat("x = {\n"
" a: 12,\n"
" interface: 1,\n"
More information about the cfe-commits
mailing list