r256247 - clang-format: [JS] Support arrays of object-type literals.
Daniel Jasper via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 22 07:48:35 PST 2015
Author: djasper
Date: Tue Dec 22 09:48:35 2015
New Revision: 256247
URL: http://llvm.org/viewvc/llvm-project?rev=256247&view=rev
Log:
clang-format: [JS] Support arrays of object-type literals.
Before:
interface I {
o: {}
[];
}
After:
interface I {
o: {}[];
}
Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp
Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=256247&r1=256246&r2=256247&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Tue Dec 22 09:48:35 2015
@@ -357,7 +357,7 @@ void UnwrappedLineParser::calculateBrace
ProbablyBracedList =
NextTok->isOneOf(tok::comma, tok::period, tok::colon,
tok::r_paren, tok::r_square, tok::l_brace,
- tok::l_paren, tok::ellipsis) ||
+ tok::l_square, tok::l_paren, tok::ellipsis) ||
(NextTok->is(tok::semi) &&
(!ExpectClassBody || LBraceStack.size() != 1)) ||
(NextTok->isBinaryOperator() && !NextIsObjCMethod);
Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=256247&r1=256246&r2=256247&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue Dec 22 09:48:35 2015
@@ -768,6 +768,11 @@ TEST_F(FormatTestJS, InterfaceDeclaratio
verifyFormat("interface a {}\n"
"export function b() {}\n"
"var x;");
+
+ // Arrays of object type literals.
+ verifyFormat("interface I {\n"
+ " o: {}[];\n"
+ "}");
}
TEST_F(FormatTestJS, EnumDeclarations) {
More information about the cfe-commits
mailing list