r253672 - clang-format: [JS] Properly add a space after "in" in for loops.
Daniel Jasper via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 20 08:18:43 PST 2015
Author: djasper
Date: Fri Nov 20 10:18:42 2015
New Revision: 253672
URL: http://llvm.org/viewvc/llvm-project?rev=253672&view=rev
Log:
clang-format: [JS] Properly add a space after "in" in for loops.
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=253672&r1=253671&r2=253672&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Nov 20 10:18:42 2015
@@ -1955,7 +1955,8 @@ 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))
+ if (Left.isOneOf(Keywords.kw_let, Keywords.kw_var, TT_JsFatArrow,
+ Keywords.kw_in))
return true;
if (Right.isOneOf(TT_JsTypeColon, TT_JsTypeOptionalQuestion))
return false;
Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=253672&r1=253671&r2=253672&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Fri Nov 20 10:18:42 2015
@@ -545,6 +545,11 @@ TEST_F(FormatTestJS, ReturnStatements) {
"}");
}
+TEST_F(FormatTestJS, ForLoops) {
+ verifyFormat("for (var i in [2, 3]) {\n"
+ "}");
+}
+
TEST_F(FormatTestJS, AutomaticSemicolonInsertion) {
// The following statements must not wrap, as otherwise the program meaning
// would change due to automatic semicolon insertion.
More information about the cfe-commits
mailing list