From 41575498a0448a90eb1ab0df77d6e62f79a9764d Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Thu, 7 Jan 2016 08:53:35 +0000 Subject: [PATCH] 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'; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@257038 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/UnwrappedLineParser.cpp | 15 +++++++-------- unittests/Format/FormatTestJS.cpp | 1 + 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index 94b8498819..27e2f84d24 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/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/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp index 2f67bdf549..c312883ee7 100644 --- a/unittests/Format/FormatTestJS.cpp +++ b/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" -- 2.50.1