diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Format/SortJavaScriptImports.cpp | 4 | ||||
-rw-r--r-- | clang/unittests/Format/SortImportsTestJS.cpp | 8 |
2 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/Format/SortJavaScriptImports.cpp b/clang/lib/Format/SortJavaScriptImports.cpp index e73695ca847..e08f4c3eec3 100644 --- a/clang/lib/Format/SortJavaScriptImports.cpp +++ b/clang/lib/Format/SortJavaScriptImports.cpp @@ -413,7 +413,7 @@ private: nextToken(); if (Current->is(tok::r_brace)) break; - if (Current->isNot(tok::identifier)) + if (!Current->isOneOf(tok::identifier, tok::kw_default)) return false; JsImportedSymbol Symbol; @@ -425,7 +425,7 @@ private: if (Current->is(Keywords.kw_as)) { nextToken(); - if (Current->isNot(tok::identifier)) + if (!Current->isOneOf(tok::identifier, tok::kw_default)) return false; Symbol.Alias = Current->TokenText; nextToken(); diff --git a/clang/unittests/Format/SortImportsTestJS.cpp b/clang/unittests/Format/SortImportsTestJS.cpp index 4208b29702d..91be0313cf8 100644 --- a/clang/unittests/Format/SortImportsTestJS.cpp +++ b/clang/unittests/Format/SortImportsTestJS.cpp @@ -300,6 +300,14 @@ TEST_F(SortImportsTestJS, SortMultiLine) { "1;"); } +TEST_F(SortImportsTestJS, SortDefaultImports) { + // Reproduces issue where multi-line import was not parsed correctly. + verifySort("import {A} from 'a';\n" + "import {default as B} from 'b';\n", + "import {default as B} from 'b';\n" + "import {A} from 'a';\n"); +} + } // end namespace } // end namespace format } // end namespace clang |