[PATCH] D22147: clang-format: [JS] support trailing commas in imports.
Martin Probst via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 8 11:41:18 PDT 2016
mprobst created this revision.
mprobst added a reviewer: djasper.
mprobst added a subscriber: cfe-commits.
Herald added a subscriber: klimek.
http://reviews.llvm.org/D22147
Files:
lib/Format/SortJavaScriptImports.cpp
unittests/Format/SortImportsTestJS.cpp
Index: unittests/Format/SortImportsTestJS.cpp
===================================================================
--- unittests/Format/SortImportsTestJS.cpp
+++ 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
Index: lib/Format/SortJavaScriptImports.cpp
===================================================================
--- lib/Format/SortJavaScriptImports.cpp
+++ 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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22147.63270.patch
Type: text/x-patch
Size: 875 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160708/4394cffa/attachment.bin>
More information about the cfe-commits
mailing list