r218119 - clang-format: [JS] add space before operator 'in'.
Daniel Jasper
djasper at google.com
Fri Sep 19 03:48:16 PDT 2014
Author: djasper
Date: Fri Sep 19 05:48:15 2014
New Revision: 218119
URL: http://llvm.org/viewvc/llvm-project?rev=218119&view=rev
Log:
clang-format: [JS] add space before operator 'in'.
Before:
return ('aaa')in bbbb;
After:
return ('aaa') in bbbb;
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=218119&r1=218118&r2=218119&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Sep 19 05:48:15 2014
@@ -868,6 +868,9 @@ private:
Tok.Previous->Type == TT_PointerOrReference ||
Tok.Previous->Type == TT_TemplateCloser ||
Tok.Previous->isSimpleTypeSpecifier();
+ if (Style.Language == FormatStyle::LK_JavaScript && Tok.Next &&
+ Tok.Next->TokenText == "in")
+ return false;
bool ParensCouldEndDecl =
Tok.Next && Tok.Next->isOneOf(tok::equal, tok::semi, tok::l_brace);
bool IsSizeOfOrAlignOf =
Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=218119&r1=218118&r2=218119&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Fri Sep 19 05:48:15 2014
@@ -81,6 +81,7 @@ TEST_F(FormatTestJS, UnderstandsJavaScri
getGoogleJSStyleWithColumns(20));
verifyFormat("var b = a.map((x) => x + 1);");
+ verifyFormat("return ('aaa') in bbbb;");
}
TEST_F(FormatTestJS, UnderstandsAmpAmp) {
More information about the cfe-commits
mailing list