]> granicus.if.org Git - clang/commitdiff
clang-format: [JS] do not wrap before yield.
authorMartin Probst <martin@probst.io>
Fri, 24 Nov 2017 17:05:35 +0000 (17:05 +0000)
committerMartin Probst <martin@probst.io>
Fri, 24 Nov 2017 17:05:35 +0000 (17:05 +0000)
Summary: The same rules apply as for `return`.

Reviewers: djasper

Subscribers: klimek

Differential Revision: https://reviews.llvm.org/D40431

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@318958 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTestJS.cpp

index 1962ab2ab99c279606552a63c840da3eede26aba..d8d8bcbfc17094229ff23d267ed4d24d22cdaebb 100644 (file)
@@ -2699,8 +2699,8 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
     const FormatToken *NonComment = Right.getPreviousNonComment();
     if (NonComment &&
-        NonComment->isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
-                            tok::kw_throw, Keywords.kw_interface,
+        NonComment->isOneOf(tok::kw_return, Keywords.kw_yield, tok::kw_continue,
+                            tok::kw_break, tok::kw_throw, Keywords.kw_interface,
                             Keywords.kw_type, tok::kw_static, tok::kw_public,
                             tok::kw_private, tok::kw_protected,
                             Keywords.kw_readonly, Keywords.kw_abstract,
index b8c81d14f4cd6a2fe9b58c2c4dbb2817ae16fea0..2665c8b428e18a1a47527fa5e13a29505536422b 100644 (file)
@@ -1123,6 +1123,7 @@ TEST_F(FormatTestJS, WrapRespectsAutomaticSemicolonInsertion) {
   // would change due to automatic semicolon insertion.
   // See http://www.ecma-international.org/ecma-262/5.1/#sec-7.9.1.
   verifyFormat("return aaaaa;", getGoogleJSStyleWithColumns(10));
+  verifyFormat("yield aaaaa;", getGoogleJSStyleWithColumns(10));
   verifyFormat("return /* hello! */ aaaaa;", getGoogleJSStyleWithColumns(10));
   verifyFormat("continue aaaaa;", getGoogleJSStyleWithColumns(10));
   verifyFormat("continue /* hello! */ aaaaa;", getGoogleJSStyleWithColumns(10));