This revision was automatically updated to reflect the committed changes.
Closed by commit rL297606: clang-format: [JS] allow breaking after non-null
assertions. (authored by mprobst).
Changed prior to commit:
https://reviews.llvm.org/D30705?vs=90988&id=91526#toc
Repository:
rL LLVM
https:/
mprobst updated this revision to Diff 90988.
mprobst marked an inline comment as done.
mprobst added a comment.
- Introduce TT_JsNonNullAssertion to centralize determining token types.
- Move up language specific code in determineTokenType.
https://reviews.llvm.org/D30705
Files:
lib/Format/Fo
mprobst marked 2 inline comments as done.
mprobst added inline comments.
Comment at: lib/Format/TokenAnnotator.cpp:1056
+} else if (Current.is(tok::exclaim)) {
+ if (Style.Language == FormatStyle::LK_JavaScript) {
+if (Current.Previous &&
djasper
djasper accepted this revision.
djasper added inline comments.
This revision is now accepted and ready to land.
Comment at: lib/Format/TokenAnnotator.cpp:1056
+} else if (Current.is(tok::exclaim)) {
+ if (Style.Language == FormatStyle::LK_JavaScript) {
+if (Curre
mprobst updated this revision to Diff 90889.
mprobst added a comment.
- Introduce TT_JsNonNullAssertion to centralize determining token types.
https://reviews.llvm.org/D30705
Files:
lib/Format/FormatToken.h
lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTestJS.cpp
Index: unittests
djasper added inline comments.
Comment at: lib/Format/TokenAnnotator.cpp:2292
return false;
-// Postfix non-null assertion operator, as in `foo!.bar()`.
-if (Right.is(tok::exclaim) && (Left.isOneOf(tok::identifier, tok::r_paren,
-
mprobst created this revision.
Herald added a subscriber: klimek.
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-