[PATCH] D47193: clang-format: [JS] do not wrap before any `is`.

Martin Probst via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 22 03:43:05 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rC332968: clang-format: [JS] do not wrap before any `is`. (authored by mprobst, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47193?vs=147978&id=147979#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47193

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


Index: lib/Format/TokenAnnotator.cpp
===================================================================
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2958,7 +2958,7 @@
       return false;
     if (Left.is(TT_JsTypeColon))
       return true;
-    if (Right.NestingLevel == 0 && Right.is(Keywords.kw_is))
+    if (Right.is(Keywords.kw_is))
       return false;
     if (Left.is(Keywords.kw_in))
       return Style.BreakBeforeBinaryOperators == FormatStyle::BOS_None;
Index: unittests/Format/FormatTestJS.cpp
===================================================================
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1164,7 +1164,15 @@
   verifyFormat("await theReckoning;", getGoogleJSStyleWithColumns(10));
   verifyFormat("some['a']['b']", getGoogleJSStyleWithColumns(10));
   verifyFormat("x = (a['a']\n"
-               "      ['b']);", getGoogleJSStyleWithColumns(10));
+               "      ['b']);",
+               getGoogleJSStyleWithColumns(10));
+  verifyFormat("function f() {\n"
+               "  return foo.bar(\n"
+               "      (param): param is {\n"
+               "        a: SomeType\n"
+               "      }&ABC => 1)\n"
+               "}",
+               getGoogleJSStyleWithColumns(25));
 }
 
 TEST_F(FormatTestJS, AutomaticSemicolonInsertionHeuristic) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47193.147979.patch
Type: text/x-patch
Size: 1361 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180522/361c021f/attachment-0001.bin>


More information about the cfe-commits mailing list