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;
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;
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits