diff options
author | Krasimir Georgiev <krasimir@google.com> | 2018-07-30 08:45:45 +0000 |
---|---|---|
committer | Krasimir Georgiev <krasimir@google.com> | 2018-07-30 08:45:45 +0000 |
commit | 6a5c95bd6643a78b5bc1df7397444138956ffbc0 (patch) | |
tree | e7409e3697234de49f96f0acda6079bf858f8f40 /clang/unittests/Format/FormatTestJS.cpp | |
parent | e5899447b40355ad0a79db6e04f8f1d5293d8fd1 (diff) | |
download | bcm5719-llvm-6a5c95bd6643a78b5bc1df7397444138956ffbc0.tar.gz bcm5719-llvm-6a5c95bd6643a78b5bc1df7397444138956ffbc0.zip |
[clang-format] Indent after breaking Javadoc annotated line
Summary:
This patch makes clang-format indent the subsequent lines created by breaking a
long javadoc annotated line.
Reviewers: mprobst
Reviewed By: mprobst
Subscribers: acoomans, cfe-commits
Differential Revision: https://reviews.llvm.org/D49797
llvm-svn: 338232
Diffstat (limited to 'clang/unittests/Format/FormatTestJS.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTestJS.cpp | 77 |
1 files changed, 46 insertions, 31 deletions
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index 9975b7d3112..e7808c6596d 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -191,19 +191,28 @@ TEST_F(FormatTestJS, JSDocComments) { // Break a single line long jsdoc comment pragma. EXPECT_EQ("/**\n" - " * @returns {string} jsdoc line 12\n" + " * @returns\n" + " * {string}\n" + " * jsdoc line 12\n" " */", format("/** @returns {string} jsdoc line 12 */", getGoogleJSStyleWithColumns(20))); EXPECT_EQ("/**\n" - " * @returns {string} jsdoc line 12\n" + " * @returns\n" + " * {string}\n" + " * jsdoc line 12\n" " */", format("/** @returns {string} jsdoc line 12 */", getGoogleJSStyleWithColumns(20))); + // FIXME: this overcounts the */ as a continuation of the 12 when breaking. + // Related to the FIXME in BreakableBlockComment::getRangeLength. EXPECT_EQ("/**\n" - " * @returns {string} jsdoc line 12\n" + " * @returns\n" + " * {string}\n" + " * jsdoc line\n" + " * 12\n" " */", format("/** @returns {string} jsdoc line 12*/", getGoogleJSStyleWithColumns(20))); @@ -212,7 +221,8 @@ TEST_F(FormatTestJS, JSDocComments) { EXPECT_EQ("/**\n" " * line 1\n" " * line 2\n" - " * @returns {string} jsdoc line 12\n" + " * @returns {string}\n" + " * jsdoc line 12\n" " */", format("/** line 1\n" " * line 2\n" @@ -2028,21 +2038,24 @@ TEST_F(FormatTestJS, WrapAfterParen) { TEST_F(FormatTestJS, JSDocAnnotations) { verifyFormat("/**\n" - " * @export {this.is.a.long.path.to.a.Type}\n" + " * @exports\n" + " * {this.is.a.long.path.to.a.Type}\n" " */", "/**\n" - " * @export {this.is.a.long.path.to.a.Type}\n" + " * @exports {this.is.a.long.path.to.a.Type}\n" " */", getGoogleJSStyleWithColumns(20)); verifyFormat("/**\n" - " * @mods {this.is.a.long.path.to.a.Type}\n" + " * @mods\n" + " * {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" + " * @param\n" + " * {this.is.a.long.path.to.a.Type}\n" " */", "/**\n" " * @param {this.is.a.long.path.to.a.Type}\n" @@ -2058,34 +2071,36 @@ TEST_F(FormatTestJS, JSDocAnnotations) { verifyFormat( "/**\n" " * @param This is a\n" - " * long comment but\n" - " * no type\n" + " * long comment\n" + " * but no type\n" " */", "/**\n" " * @param This is a long comment but no type\n" " */", getGoogleJSStyleWithColumns(20)); - // Don't break @param line, but reindent it and reflow unrelated lines. - verifyFormat("{\n" - " /**\n" - " * long long long\n" - " * long\n" - " * @param {this.is.a.long.path.to.a.Type} a\n" - " * long long long\n" - " * long long\n" - " */\n" - " function f(a) {}\n" - "}", - "{\n" - "/**\n" - " * long long long long\n" - " * @param {this.is.a.long.path.to.a.Type} a\n" - " * long long long long\n" - " * long\n" - " */\n" - " function f(a) {}\n" - "}", - getGoogleJSStyleWithColumns(20)); + // Break and reindent @param line and reflow unrelated lines. + EXPECT_EQ("{\n" + " /**\n" + " * long long long\n" + " * long\n" + " * @param\n" + " * {this.is.a.long.path.to.a.Type}\n" + " * a\n" + " * long long long\n" + " * long long\n" + " */\n" + " function f(a) {}\n" + "}", + format("{\n" + "/**\n" + " * long long long long\n" + " * @param {this.is.a.long.path.to.a.Type} a\n" + " * long long long long\n" + " * long\n" + " */\n" + " function f(a) {}\n" + "}", + getGoogleJSStyleWithColumns(20))); } TEST_F(FormatTestJS, RequoteStringsSingle) { |