r285569 - clang-format: [JS] Fix missing space after 'yield'.
Daniel Jasper via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 31 06:18:26 PDT 2016
Author: djasper
Date: Mon Oct 31 08:18:25 2016
New Revision: 285569
URL: http://llvm.org/viewvc/llvm-project?rev=285569&view=rev
Log:
clang-format: [JS] Fix missing space after 'yield'.
Before:
class X {
delete(val) {
return null;
}
* gen() {
yield[1, 2];
}
* gen() {
yield{a: 1};
}
};
After:
class X {
delete(val) {
return null;
}
* gen() {
yield [1, 2];
}
* gen() {
yield {a: 1};
}
};
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=285569&r1=285568&r2=285569&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Oct 31 08:18:25 2016
@@ -2133,6 +2133,9 @@ bool TokenAnnotator::spaceRequiredBefore
if (Right.is(tok::star) &&
Left.isOneOf(Keywords.kw_function, Keywords.kw_yield))
return false;
+ if (Right.isOneOf(tok::l_brace, tok::l_square) &&
+ Left.isOneOf(Keywords.kw_function, Keywords.kw_yield))
+ return true;
// JS methods can use some keywords as names (e.g. `delete()`).
if (Right.is(tok::l_paren) && Line.MustBeDeclaration &&
Left.Tok.getIdentifierInfo())
Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=285569&r1=285568&r2=285569&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Mon Oct 31 08:18:25 2016
@@ -368,6 +368,8 @@ TEST_F(FormatTestJS, GeneratorFunctions)
" let x = 1;\n"
" yield x;\n"
" yield* something();\n"
+ " yield [1, 2];\n"
+ " yield {a: 1};\n"
"}");
verifyFormat("function*\n"
" f() {\n"
More information about the cfe-commits
mailing list