krasimir created this revision. krasimir requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
As a follow-up from https://reviews.llvm.org/D108538, ensure TypeScript argument decorators are kept in line with the argument. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D108620 Files: clang/lib/Format/ContinuationIndenter.cpp clang/unittests/Format/FormatTestJS.cpp Index: clang/unittests/Format/FormatTestJS.cpp =================================================================== --- clang/unittests/Format/FormatTestJS.cpp +++ clang/unittests/Format/FormatTestJS.cpp @@ -701,8 +701,12 @@ getGoogleJSStyleWithColumns(20))); } -TEST_F(FormatTestJS, FormatsDecoratedFunctions) { - // Regression test: ensure that there is a break before `get`. +TEST_F(FormatTestJS, FormatsDecorators) { + // No line break after argument decorators. + verifyFormat("class A {\n" + " constructor(@arg(DECOR) private arg: Type) {}\n" + "}"); + // Ensure that there is a break before `get`. EXPECT_EQ("class A {\n" " private p = () => {}\n" "\n" Index: clang/lib/Format/ContinuationIndenter.cpp =================================================================== --- clang/lib/Format/ContinuationIndenter.cpp +++ clang/lib/Format/ContinuationIndenter.cpp @@ -492,9 +492,10 @@ return true; } - // Break after the closing parenthesis of TypeScript decorators. + // Break after the closing parenthesis of TypeScript decorators before `get`. if (Style.Language == FormatStyle::LK_JavaScript && - Previous.is(tok::r_paren) && Previous.is(TT_JavaAnnotation)) { + Current.TokenText == "get" && Previous.is(tok::r_paren) && + Previous.is(TT_JavaAnnotation)) { return true; }
Index: clang/unittests/Format/FormatTestJS.cpp =================================================================== --- clang/unittests/Format/FormatTestJS.cpp +++ clang/unittests/Format/FormatTestJS.cpp @@ -701,8 +701,12 @@ getGoogleJSStyleWithColumns(20))); } -TEST_F(FormatTestJS, FormatsDecoratedFunctions) { - // Regression test: ensure that there is a break before `get`. +TEST_F(FormatTestJS, FormatsDecorators) { + // No line break after argument decorators. + verifyFormat("class A {\n" + " constructor(@arg(DECOR) private arg: Type) {}\n" + "}"); + // Ensure that there is a break before `get`. EXPECT_EQ("class A {\n" " private p = () => {}\n" "\n" Index: clang/lib/Format/ContinuationIndenter.cpp =================================================================== --- clang/lib/Format/ContinuationIndenter.cpp +++ clang/lib/Format/ContinuationIndenter.cpp @@ -492,9 +492,10 @@ return true; } - // Break after the closing parenthesis of TypeScript decorators. + // Break after the closing parenthesis of TypeScript decorators before `get`. if (Style.Language == FormatStyle::LK_JavaScript && - Previous.is(tok::r_paren) && Previous.is(TT_JavaAnnotation)) { + Current.TokenText == "get" && Previous.is(tok::r_paren) && + Previous.is(TT_JavaAnnotation)) { return true; }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits