clang-format: [JS] Fix failing format with TypeScript casts.

Before, this could be formatted at all (with BracketAlignmentStyle
AlwaysBreak):

  foo = <Bar[]>[
    1, /* */
    2
  ];

llvm-svn: 272668
This commit is contained in:
Daniel Jasper 2016-06-14 13:54:38 +00:00
parent c49f6ce3e1
commit 887a399418
2 changed files with 7 additions and 3 deletions

View File

@ -319,9 +319,9 @@ private:
Left->Type = TT_JsComputedPropertyName;
} else if (Style.Language == FormatStyle::LK_Proto ||
(Parent &&
Parent->isOneOf(TT_BinaryOperator, tok::at, tok::comma,
tok::l_paren, tok::l_square, tok::question,
tok::colon, tok::kw_return,
Parent->isOneOf(TT_BinaryOperator, TT_TemplateCloser, tok::at,
tok::comma, tok::l_paren, tok::l_square,
tok::question, tok::colon, tok::kw_return,
// Should only be relevant to JavaScript:
tok::kw_default))) {
Left->Type = TT_ArrayInitializerLSquare;

View File

@ -1205,6 +1205,10 @@ TEST_F(FormatTestJS, TemplateStrings) {
TEST_F(FormatTestJS, CastSyntax) {
verifyFormat("var x = <type>foo;");
verifyFormat("var x = foo as type;");
verifyFormat("foo = <Bar[]>[\n"
" 1, //\n"
" 2\n"
"];");
}
TEST_F(FormatTestJS, TypeArguments) {