[PATCH] D24257: clang-format: [JS] ignore comments when wrapping returns.

Daniel Jasper via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 6 11:46:40 PDT 2016


djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good.


================
Comment at: lib/Format/TokenAnnotator.cpp:2384
@@ -2383,2 +2383,3 @@
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
-    if (Left.is(tok::kw_return))
+    const FormatToken *NonComment = Right.getPreviousNonComment();
+    if (Left.isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
----------------
mprobst wrote:
> Should the entire method generally consider the previous non-comment, instead of just the previous token? Not sure if that makes sense in all cases, and I don't think we always have a previous non-comment token either.
Lets leave this as is for now. Yes, some of these should likely look past comments, but probably not all of them.


https://reviews.llvm.org/D24257





More information about the cfe-commits mailing list