Skip to content

Commit

Permalink
Blacklist arbitrary @\\w+ JSDoc tags from wrapping.
Browse files Browse the repository at this point in the history
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

llvm-svn: 296467
  • Loading branch information
mprobst committed Feb 28, 2017
1 parent 6159f12 commit bb46a7d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
4 changes: 2 additions & 2 deletions clang/lib/Format/Format.cpp
Expand Up @@ -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;
Expand Down
24 changes: 24 additions & 0 deletions clang/unittests/Format/FormatTestJS.cpp
Expand Up @@ -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) {
Expand Down

0 comments on commit bb46a7d

Please sign in to comment.