[PATCH] D23761: clang-format: [JS] supports casts to types starting with punctuation ("{[(").

Martin Probst via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 22 07:31:44 PDT 2016


This revision was automatically updated to reflect the committed changes.
mprobst marked an inline comment as done.
Closed by commit rL279436: clang-format: [JS] supports casts to types starting with punctuation ("{[("). (authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D23761?vs=68844&id=68858#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23761

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

Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -2121,6 +2121,9 @@
                      Keywords.kw_of, tok::kw_const) &&
         (!Left.Previous || !Left.Previous->is(tok::period)))
       return true;
+    if (Left.is(Keywords.kw_as) &&
+        Right.isOneOf(tok::l_square, tok::l_brace, tok::l_paren))
+      return true;
     if (Left.is(tok::kw_default) && Left.Previous &&
         Left.Previous->is(tok::kw_export))
       return true;
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1219,6 +1219,9 @@
                "  2\n"
                "];");
   verifyFormat("var x = [{x: 1} as type];");
+  verifyFormat("x = x as [a, b];");
+  verifyFormat("x = x as {a: string};");
+  verifyFormat("x = x as (string);");
 }
 
 TEST_F(FormatTestJS, TypeArguments) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23761.68858.patch
Type: text/x-patch
Size: 1096 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160822/9804ab04/attachment.bin>


More information about the cfe-commits mailing list