]> granicus.if.org Git - clang/commitdiff
Blacklist arbitrary @\\w+ JSDoc tags from wrapping.
authorMartin Probst <martin@probst.io>
Tue, 28 Feb 2017 11:08:24 +0000 (11:08 +0000)
committerMartin Probst <martin@probst.io>
Tue, 28 Feb 2017 11:08:24 +0000 (11:08 +0000)
Summary:
Also limits the blacklisting to only apply when the tag is actually
followed by a parameter in curly braces.

    /** @mods {long.type.must.not.wrap} */

vs

    /** @const this is a long description that may wrap. */

Reviewers: djasper

Subscribers: klimek, krasimir, cfe-commits

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

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

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

index 99787408133b3de99dca4f570285b36aadb54500..28e997787147c12c53214fa358640ad1c65cec72 100644 (file)
@@ -620,8 +620,8 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language) {
     GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
     GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
     GoogleStyle.BreakBeforeTernaryOperators = false;
-    GoogleStyle.CommentPragmas =
-        "(taze:|@(export|requirecss|return|returns|see|visibility)) ";
+    // taze:, and @tag followed by { for a lot of JSDoc tags.
+    GoogleStyle.CommentPragmas = "(taze:|(@[A-Za-z_0-9-]+[ \\t]*{))";
     GoogleStyle.MaxEmptyLinesToKeep = 3;
     GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
     GoogleStyle.SpacesInContainerLiterals = false;
index 112b124398b4b266964d49c647467bb4e92ab558..d6e14edf87132e208e75fcdaf9426a3052eb6587 100644 (file)
@@ -1575,6 +1575,30 @@ TEST_F(FormatTestJS, JSDocAnnotations) {
                " * @export {this.is.a.long.path.to.a.Type}\n"
                " */",
                getGoogleJSStyleWithColumns(20));
+  verifyFormat("/**\n"
+               " * @mods {this.is.a.long.path.to.a.Type}\n"
+               " */",
+               "/**\n"
+               " * @mods {this.is.a.long.path.to.a.Type}\n"
+               " */",
+               getGoogleJSStyleWithColumns(20));
+  verifyFormat("/**\n"
+               " * @param {this.is.a.long.path.to.a.Type}\n"
+               " */",
+               "/**\n"
+               " * @param {this.is.a.long.path.to.a.Type}\n"
+               " */",
+               getGoogleJSStyleWithColumns(20));
+  verifyFormat(
+      "/**\n"
+      " * @param This is a\n"
+      " * long comment but\n"
+      " * no type\n"
+      " */",
+      "/**\n"
+      " * @param This is a long comment but no type\n"
+      " */",
+      getGoogleJSStyleWithColumns(20));
 }
 
 TEST_F(FormatTestJS, RequoteStringsSingle) {