From: Daniel Jasper Date: Tue, 22 Dec 2015 15:48:35 +0000 (+0000) Subject: clang-format: [JS] Support arrays of object-type literals. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=43581a0db408529aaa98ca8880b85a02a164f0be;p=clang clang-format: [JS] Support arrays of object-type literals. Before: interface I { o: {} []; } After: interface I { o: {}[]; } git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256247 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index ac534a2abe..1213332d27 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -357,7 +357,7 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) { 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); diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp index 93a4eba4a9..9bfd587412 100644 --- a/unittests/Format/FormatTestJS.cpp +++ b/unittests/Format/FormatTestJS.cpp @@ -768,6 +768,11 @@ TEST_F(FormatTestJS, InterfaceDeclarations) { 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) {