]> granicus.if.org Git - clang/commitdiff
clang-format: [JS] Keep space after closure style comments.
authorDaniel Jasper <djasper@google.com>
Tue, 6 May 2014 14:41:29 +0000 (14:41 +0000)
committerDaniel Jasper <djasper@google.com>
Tue, 6 May 2014 14:41:29 +0000 (14:41 +0000)
Before:
  var x = /** @type {foo} */ (bar);

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208093 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTestJS.cpp

index e873e984605fb49ed101e0874fb09d4d8ef4a111..8becd00897a2f415eabd8216716dcd8437b5acda 100644 (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);
index 153b07535ee99b2a256db455583f4eb3b42a3970..ee49912522aece7447e3f88bd0ca9b16db0807e6 100644 (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