r296467 - Blacklist arbitrary @\\w+ JSDoc tags from wrapping.
Martin Probst via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 28 03:08:24 PST 2017
Author: mprobst
Date: Tue Feb 28 05:08:24 2017
New Revision: 296467
URL: http://llvm.org/viewvc/llvm-project?rev=296467&view=rev
Log:
Blacklist arbitrary @\\w+ JSDoc tags from wrapping.
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
Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp
Modified: cfe/trunk/lib/Format/Format.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=296467&r1=296466&r2=296467&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Tue Feb 28 05:08:24 2017
@@ -620,8 +620,8 @@ FormatStyle getGoogleStyle(FormatStyle::
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;
Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=296467&r1=296466&r2=296467&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue Feb 28 05:08:24 2017
@@ -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) {
More information about the cfe-commits
mailing list