clang-format: [JS] Support arrays of object-type literals.

Before:
  interface I {
    o: {}
    [];
  }

After:
  interface I {
    o: {}[];
  }

llvm-svn: 256247
This commit is contained in:
Daniel Jasper 2015-12-22 15:48:35 +00:00
parent e2deb59fa3
commit b542f9f144
2 changed files with 6 additions and 1 deletions

View File

@ -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);

View File

@ -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) {