Summary: Formerly, `import {default as X} from y;` would not be recognized as an import.
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D36132
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@309697
91177308-0d34-0410-b5e6-
96231b3b80d8
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;
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();
"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