From b542f9f1442569d6247877ba8bfab51008544e9f Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Tue, 22 Dec 2015 15:48:35 +0000 Subject: [PATCH] clang-format: [JS] Support arrays of object-type literals. Before: interface I { o: {} []; } After: interface I { o: {}[]; } llvm-svn: 256247 --- clang/lib/Format/UnwrappedLineParser.cpp | 2 +- clang/unittests/Format/FormatTestJS.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index ac534a2..1213332 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/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/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index 93a4eba..9bfd587 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/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) { -- 2.7.4