[PATCH] D18943: clang-format: [JS] do not insert semicolons after wrapped annotations.

Martin Probst via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 11 00:41:34 PDT 2016


This revision was automatically updated to reflect the committed changes.
mprobst marked an inline comment as done.
Closed by commit rL265916: clang-format: [JS] do not insert semicolons after wrapped annotations. (authored by mprobst).

Changed prior to commit:
  http://reviews.llvm.org/D18943?vs=53190&id=53199#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18943

Files:
  cfe/trunk/lib/Format/UnwrappedLineParser.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp

Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -715,6 +715,13 @@
     return;
 
   bool PreviousMustBeValue = mustBeJSIdentOrValue(Keywords, Previous);
+  if (PreviousMustBeValue && Line && Line->Tokens.size() > 1) {
+    // If the token before the previous one is an '@', the previous token is an
+    // annotation and can precede another identifier/value.
+    const FormatToken *PrePrevious = std::next(Line->Tokens.rend(), 2)->Tok;
+    if (PrePrevious->is(tok::at))
+      return;
+  }
   if (Next->is(tok::exclaim) && PreviousMustBeValue)
     addUnwrappedLine();
   bool NextMustBeValue = mustBeJSIdentOrValue(Keywords, Next);
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -686,6 +686,8 @@
   verifyFormat("x instanceof String", "x\n"
                                       "instanceof\n"
                                       "String");
+  verifyFormat("function f(@Foo bar) {}", "function f(@Foo\n"
+                                          "  bar) {}");
 }
 
 TEST_F(FormatTestJS, ClosureStyleCasts) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18943.53199.patch
Type: text/x-patch
Size: 1361 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160411/e079442e/attachment.bin>


More information about the cfe-commits mailing list