]> granicus.if.org Git - clang/commitdiff
clang-format: [JS] space after parameter naming.
authorMartin Probst <martin@probst.io>
Wed, 26 Sep 2018 08:28:33 +0000 (08:28 +0000)
committerMartin Probst <martin@probst.io>
Wed, 26 Sep 2018 08:28:33 +0000 (08:28 +0000)
Summary:
Previously:
    foo(/*bar=*/baz);

Now:
    foo(/*bar=*/ baz);

The run-in parameter naming comment is not intended in JS.

Reviewers: mboehme

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D52535

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

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

index 3a19215e18037c12bbca9b0503994811f5d1281a..83c5b2e8b96402f821e276ed95849d464394a4d1 100644 (file)
@@ -2517,7 +2517,9 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
        Right.MatchingParen->BlockKind != BK_Block))
     return !Style.Cpp11BracedListStyle;
   if (Left.is(TT_BlockComment))
-    return !Left.TokenText.endswith("=*/");
+    // No whitespace in x(/*foo=*/1), except for JavaScript.
+    return Style.Language == FormatStyle::LK_JavaScript ||
+           !Left.TokenText.endswith("=*/");
   if (Right.is(tok::l_paren)) {
     if ((Left.is(tok::r_paren) && Left.is(TT_AttributeParen)) ||
         (Left.is(tok::r_square) && Left.is(TT_AttributeSquare)))
index 8346783738952e3b9419a1c6953b392a7910b26a..ba0700edd4fa5751670d13e33e3bcb2a1081e10e 100644 (file)
@@ -2304,5 +2304,9 @@ TEST_F(FormatTestJS, AddsLastLinePenaltyIfEndingIsBroken) {
              "};"));
 }
 
+TEST_F(FormatTestJS, ParameterNamingComment) {
+  verifyFormat("callFoo(/*spaceAfterParameterNamingComment=*/ 1);");
+}
+
 } // end namespace tooling
 } // end namespace clang