summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2016-01-07 08:53:35 +0000
committerDaniel Jasper <djasper@google.com>2016-01-07 08:53:35 +0000
commitefc1a83a998556f1930c4072027ec83eb63465ce (patch)
tree0036af3629542bbb684a43f64f4bda3fc358eff5 /clang
parenta809acec40d974e165171a9f60a05060d84d18a4 (diff)
downloadbcm5719-llvm-efc1a83a998556f1930c4072027ec83eb63465ce.tar.gz
bcm5719-llvm-efc1a83a998556f1930c4072027ec83eb63465ce.zip
clang-format: [JS] Support more ES6 imports.
Before: import a, {X, Y} from 'some/module.js'; After: import a, {X, Y} from 'some/module.js'; llvm-svn: 257038
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp15
-rw-r--r--clang/unittests/Format/FormatTestJS.cpp1
2 files changed, 8 insertions, 8 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 94b84988194..27e2f84d245 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -1796,14 +1796,13 @@ void UnwrappedLineParser::parseJavaScriptEs6ImportExport() {
Keywords.kw_let, Keywords.kw_var))
return; // Fall through to parsing the corresponding structure.
- if (FormatTok->is(tok::l_brace)) {
- FormatTok->BlockKind = BK_Block;
- parseBracedList();
- }
-
- while (!eof() && FormatTok->isNot(tok::semi) &&
- FormatTok->isNot(tok::l_brace)) {
- nextToken();
+ while (!eof() && FormatTok->isNot(tok::semi)) {
+ if (FormatTok->is(tok::l_brace)) {
+ FormatTok->BlockKind = BK_Block;
+ parseBracedList();
+ } else {
+ nextToken();
+ }
}
}
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index 2f67bdf549c..c312883ee77 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -812,6 +812,7 @@ TEST_F(FormatTestJS, MetadataAnnotations) {
TEST_F(FormatTestJS, Modules) {
verifyFormat("import SomeThing from 'some/module.js';");
verifyFormat("import {X, Y} from 'some/module.js';");
+ verifyFormat("import a, {X, Y} from 'some/module.js';");
verifyFormat("import {\n"
" VeryLongImportsAreAnnoying,\n"
" VeryLongImportsAreAnnoying,\n"
OpenPOWER on IntegriCloud