r274976 - clang-format: [JS] support trailing commas in imports.
Martin Probst via cfe-commits
cfe-commits at lists.llvm.org
Sat Jul 9 08:09:22 PDT 2016
Author: mprobst
Date: Sat Jul 9 10:09:22 2016
New Revision: 274976
URL: http://llvm.org/viewvc/llvm-project?rev=274976&view=rev
Log:
clang-format: [JS] support trailing commas in imports.
Reviewers: djasper
Subscribers: cfe-commits, klimek
Differential Revision: http://reviews.llvm.org/D22147
Modified:
cfe/trunk/lib/Format/SortJavaScriptImports.cpp
cfe/trunk/unittests/Format/SortImportsTestJS.cpp
Modified: cfe/trunk/lib/Format/SortJavaScriptImports.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/SortJavaScriptImports.cpp?rev=274976&r1=274975&r2=274976&view=diff
==============================================================================
--- cfe/trunk/lib/Format/SortJavaScriptImports.cpp (original)
+++ cfe/trunk/lib/Format/SortJavaScriptImports.cpp Sat Jul 9 10:09:22 2016
@@ -396,6 +396,8 @@ private:
// {sym as alias, sym2 as ...} from '...';
nextToken();
while (true) {
+ if (Current->is(tok::r_brace))
+ return true;
if (Current->isNot(tok::identifier))
return false;
Modified: cfe/trunk/unittests/Format/SortImportsTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/SortImportsTestJS.cpp?rev=274976&r1=274975&r2=274976&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/SortImportsTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/SortImportsTestJS.cpp Sat Jul 9 10:09:22 2016
@@ -236,6 +236,10 @@ TEST_F(SortImportsTestJS, SortingCanShri
"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
More information about the cfe-commits
mailing list