diff options
| author | Martin Probst <martin@probst.io> | 2016-07-09 15:09:22 +0000 |
|---|---|---|
| committer | Martin Probst <martin@probst.io> | 2016-07-09 15:09:22 +0000 |
| commit | a8c9d154b81e755e9a7181d9fded24de587b2473 (patch) | |
| tree | 7edd5d8febfc6bf149f808b2b90b04dfdc5a4ffe /clang | |
| parent | 6ec90ec2ab69bff816bff52ec02151fe82be8147 (diff) | |
| download | bcm5719-llvm-a8c9d154b81e755e9a7181d9fded24de587b2473.tar.gz bcm5719-llvm-a8c9d154b81e755e9a7181d9fded24de587b2473.zip | |
clang-format: [JS] support trailing commas in imports.
Reviewers: djasper
Subscribers: cfe-commits, klimek
Differential Revision: http://reviews.llvm.org/D22147
llvm-svn: 274976
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Format/SortJavaScriptImports.cpp | 2 | ||||
| -rw-r--r-- | clang/unittests/Format/SortImportsTestJS.cpp | 4 |
2 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/Format/SortJavaScriptImports.cpp b/clang/lib/Format/SortJavaScriptImports.cpp index 73586d59d50..8010e4914f0 100644 --- a/clang/lib/Format/SortJavaScriptImports.cpp +++ b/clang/lib/Format/SortJavaScriptImports.cpp @@ -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; diff --git a/clang/unittests/Format/SortImportsTestJS.cpp b/clang/unittests/Format/SortImportsTestJS.cpp index cc408ca9da7..769fa793da3 100644 --- a/clang/unittests/Format/SortImportsTestJS.cpp +++ b/clang/unittests/Format/SortImportsTestJS.cpp @@ -236,6 +236,10 @@ TEST_F(SortImportsTestJS, SortingCanShrink) { "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 |

