[PATCH] D22147: clang-format: [JS] support trailing commas in imports.

Martin Probst via cfe-commits cfe-commits at lists.llvm.org
Sat Jul 9 08:16:37 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL274976: clang-format: [JS] support trailing commas in imports. (authored by mprobst).

Changed prior to commit:
  http://reviews.llvm.org/D22147?vs=63270&id=63390#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D22147

Files:
  cfe/trunk/lib/Format/SortJavaScriptImports.cpp
  cfe/trunk/unittests/Format/SortImportsTestJS.cpp

Index: cfe/trunk/lib/Format/SortJavaScriptImports.cpp
===================================================================
--- cfe/trunk/lib/Format/SortJavaScriptImports.cpp
+++ cfe/trunk/lib/Format/SortJavaScriptImports.cpp
@@ -396,6 +396,8 @@
     // {sym as alias, sym2 as ...} from '...';
     nextToken();
     while (true) {
+      if (Current->is(tok::r_brace))
+        return true;
       if (Current->isNot(tok::identifier))
         return false;
 
Index: cfe/trunk/unittests/Format/SortImportsTestJS.cpp
===================================================================
--- cfe/trunk/unittests/Format/SortImportsTestJS.cpp
+++ cfe/trunk/unittests/Format/SortImportsTestJS.cpp
@@ -236,6 +236,10 @@
              "1;");
 }
 
+TEST_F(SortImportsTestJS, TrailingComma) {
+  verifySort("import {A, B,} from 'aa';\n", "import {B, A,} from 'aa';\n");
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22147.63390.patch
Type: text/x-patch
Size: 935 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160709/3b61cab1/attachment.bin>


More information about the cfe-commits mailing list