]> granicus.if.org Git - clang/commitdiff
clang-format: [JS] Support arrays of object-type literals.
authorDaniel Jasper <djasper@google.com>
Tue, 22 Dec 2015 15:48:35 +0000 (15:48 +0000)
committerDaniel Jasper <djasper@google.com>
Tue, 22 Dec 2015 15:48:35 +0000 (15:48 +0000)
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

lib/Format/UnwrappedLineParser.cpp
unittests/Format/FormatTestJS.cpp

index ac534a2abe537dc695abcf488f8db2f68623aec8..1213332d2734369657f6796fb40c54fb56672509 100644 (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);
index 93a4eba4a93ff6a394de5ae9fd753899fbeeeb6b..9bfd587412d3595d114b5aa026a180e600869e1b 100644 (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) {