[PATCH] D30452: Blacklist @mods and several other JSDoc tags from wrapping.
Martin Probst via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 28 02:49:06 PST 2017
mprobst created this revision.
Herald added a subscriber: klimek.
Limit 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. */
JSDoc tag reference here:
https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler
https://reviews.llvm.org/D30452
Files:
lib/Format/Format.cpp
unittests/Format/FormatTestJS.cpp
Index: unittests/Format/FormatTestJS.cpp
===================================================================
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1575,6 +1575,30 @@
" * @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) {
Index: lib/Format/Format.cpp
===================================================================
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -620,8 +620,29 @@
GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
GoogleStyle.BreakBeforeTernaryOperators = false;
+ // taze:, and @tag followed by { for a lot of JSDoc tags.
GoogleStyle.CommentPragmas =
- "(taze:|@(export|requirecss|return|returns|see|visibility)) ";
+ "(taze:|"
+ "(@("
+ "const|"
+ "define|"
+ "enum|"
+ "export|"
+ "extends|"
+ "implements|"
+ "modName|"
+ "mods|"
+ "param|"
+ "private|"
+ "public|"
+ "requirecss|"
+ "returns|"
+ "return|"
+ "see|"
+ "this|"
+ "visibility"
+ ") *{)"
+ ")";
GoogleStyle.MaxEmptyLinesToKeep = 3;
GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
GoogleStyle.SpacesInContainerLiterals = false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30452.89995.patch
Type: text/x-patch
Size: 2261 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170228/e0615d96/attachment.bin>
More information about the cfe-commits
mailing list