From: Martin Probst Date: Wed, 26 Sep 2018 08:28:33 +0000 (+0000) Subject: clang-format: [JS] space after parameter naming. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a723865994f8a8e7d1bd895ff6b36401c8a1319c;p=clang clang-format: [JS] space after parameter naming. 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 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 3a19215e18..83c5b2e8b9 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -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))) diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp index 8346783738..ba0700edd4 100644 --- a/unittests/Format/FormatTestJS.cpp +++ b/unittests/Format/FormatTestJS.cpp @@ -2304,5 +2304,9 @@ TEST_F(FormatTestJS, AddsLastLinePenaltyIfEndingIsBroken) { "};")); } +TEST_F(FormatTestJS, ParameterNamingComment) { + verifyFormat("callFoo(/*spaceAfterParameterNamingComment=*/ 1);"); +} + } // end namespace tooling } // end namespace clang