clang-format: [JS] Keep space after closure style comments.

Before:
  var x = /** @type {foo} */ (bar);

After:
  var x = /** @type {foo} */(bar);

llvm-svn: 208093
This commit is contained in:
Daniel Jasper 2014-05-06 14:41:29 +00:00
parent 7a733480c8
commit 484033b188
2 changed files with 6 additions and 2 deletions

View File

@ -1457,6 +1457,8 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
return false;
if (Left.is(tok::colon))
return Left.Type != TT_ObjCMethodExpr;
if (Left.Type == TT_BlockComment)
return !Left.TokenText.endswith("=*/");
if (Right.is(tok::l_paren)) {
if (Left.is(tok::r_paren) && Left.Type == TT_AttributeParen)
return true;
@ -1478,8 +1480,6 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
(Right.is(tok::r_brace) && Right.MatchingParen &&
Right.MatchingParen->BlockKind != BK_Block))
return !Style.Cpp11BracedListStyle;
if (Left.Type == TT_BlockComment && Left.TokenText.endswith("=*/"))
return false;
if (Right.Type == TT_UnaryOperator)
return !Left.isOneOf(tok::l_paren, tok::l_square, tok::at) &&
(Left.isNot(tok::colon) || Left.Type != TT_ObjCMethodExpr);

View File

@ -102,5 +102,9 @@ TEST_F(FormatTestJS, ReturnStatements) {
verifyFormat("function() { return [hello, world]; }");
}
TEST_F(FormatTestJS, ClosureStyleComments) {
verifyFormat("var x = /** @type {foo} */ (bar);");
}
} // end namespace tooling
} // end namespace clang