clang-format: [JS] allow breaking after non-null assertions.
Summary:
Previously clang-format would not break after any !. However in TypeScript, ! can be used as a post fix operator for non-nullability:
x.foo()!.bar()!;
With this change, clang-format will wrap after the ! if it is likely a post-fix non null operator.
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D30705
llvm-svn: 297606
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index f084467..8282506 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -1714,6 +1714,12 @@
verifyFormat("let x = (foo)!;\n");
verifyFormat("let x = foo! - 1;\n");
verifyFormat("let x = {foo: 1}!;\n");
+ verifyFormat(
+ "let x = hello.foo()!\n"
+ " .foo()!\n"
+ " .foo()!\n"
+ " .foo()!;\n",
+ getGoogleJSStyleWithColumns(20));
}
TEST_F(FormatTestJS, Conditional) {