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