diff options
author | Krasimir Georgiev <krasimir@google.com> | 2020-11-11 12:07:30 +0100 |
---|---|---|
committer | Krasimir Georgiev <krasimir@google.com> | 2020-11-11 12:27:15 +0100 |
commit | 77b484116971337c9584fe101cdf1bca7f07f4dd (patch) | |
tree | cf04518082b0b9c3b6a4d0518fe3ffe39edf6fb0 /clang/unittests/Format/FormatTestJS.cpp | |
parent | 250de7388b34500b1597d25af5c42f718ed28575 (diff) | |
download | llvm-77b484116971337c9584fe101cdf1bca7f07f4dd.zip llvm-77b484116971337c9584fe101cdf1bca7f07f4dd.tar.gz llvm-77b484116971337c9584fe101cdf1bca7f07f4dd.tar.bz2 |
[clang-format] do not break before @tags in JS comments
In JavaScript breaking before a `@tag` in a comment puts it on a new line, and
machinery that parses these comments will fail to understand such comments.
This adapts clang-format to not break before `@`. Similar functionality exists
for not breaking before `{`.
Reviewed By: mprobst
Differential Revision: https://reviews.llvm.org/D91078
Diffstat (limited to 'clang/unittests/Format/FormatTestJS.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTestJS.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index 84d76c6..8963c9f 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -188,21 +188,10 @@ TEST_F(FormatTestJS, JSDocComments) { // Break a single line long jsdoc comment pragma. EXPECT_EQ("/**\n" - " * @returns {string} jsdoc line 12\n" - " */", - format("/** @returns {string} jsdoc line 12 */", - getGoogleJSStyleWithColumns(20))); - EXPECT_EQ("/**\n" " * @returns {string}\n" " * jsdoc line 12\n" " */", format("/** @returns {string} jsdoc line 12 */", - getGoogleJSStyleWithColumns(25))); - - EXPECT_EQ("/**\n" - " * @returns {string} jsdoc line 12\n" - " */", - format("/** @returns {string} jsdoc line 12 */", getGoogleJSStyleWithColumns(20))); // FIXME: this overcounts the */ as a continuation of the 12 when breaking. @@ -2194,6 +2183,16 @@ TEST_F(FormatTestJS, JSDocAnnotations) { " */", getGoogleJSStyleWithColumns(ColumnLimit)); } + // don't break before @tags + verifyFormat("/**\n" + " * This\n" + " * tag @param\n" + " * stays.\n" + " */", + "/**\n" + " * This tag @param stays.\n" + " */", + getGoogleJSStyleWithColumns(13)); verifyFormat("/**\n" " * @see http://very/very/long/url/is/long\n" " */", |