This revision was automatically updated to reflect the committed changes.
Closed by commit rL292099: clang-format: [JS] revert over-eager ASI check. 
(authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D28763?vs=84527&id=84528#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28763

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
@@ -746,8 +746,7 @@
        Previous->isOneOf(tok::r_square, tok::r_paren, tok::plusplus,
                          tok::minusminus)))
     return addUnwrappedLine();
-  if ((PreviousMustBeValue || Previous->is(tok::r_brace)) &&
-      isJSDeclOrStmt(Keywords, Next))
+  if (PreviousMustBeValue && isJSDeclOrStmt(Keywords, Next))
     return addUnwrappedLine();
 }
 
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -858,26 +858,44 @@
                "return 1",
                "a = null\n"
                "  return   1");
+  // Below "class Y {}" should ideally be on its own line.
   verifyFormat(
       "x = {\n"
       "  a: 1\n"
-      "}\n"
-      "class Y {}",
+      "} class Y {}",
       "  x  =  {a  : 1}\n"
       "   class  Y {  }");
+  verifyFormat(
+      "if (x) {\n"
+      "}\n"
+      "return 1",
+      "if (x) {}\n"
+      " return   1");
+  verifyFormat(
+      "if (x) {\n"
+      "}\n"
+      "class X {}",
+      "if (x) {}\n"
+      " class X {}");
 }
 
 TEST_F(FormatTestJS, ImportExportASI) {
   verifyFormat(
       "import {x} from 'y'\n"
       "export function z() {}",
       "import   {x} from 'y'\n"
       "  export function z() {}");
+  // Below "class Y {}" should ideally be on its own line.
   verifyFormat(
-      "export {x}\n"
-      "class Y {}",
+      "export {x} class Y {}",
       "  export {x}\n"
       "  class  Y {\n}");
+  verifyFormat(
+      "if (x) {\n"
+      "}\n"
+      "export class Y {}",
+      "if ( x ) { }\n"
+      " export class Y {}");
 }
 
 TEST_F(FormatTestJS, ClosureStyleCasts) {


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -746,8 +746,7 @@
        Previous->isOneOf(tok::r_square, tok::r_paren, tok::plusplus,
                          tok::minusminus)))
     return addUnwrappedLine();
-  if ((PreviousMustBeValue || Previous->is(tok::r_brace)) &&
-      isJSDeclOrStmt(Keywords, Next))
+  if (PreviousMustBeValue && isJSDeclOrStmt(Keywords, Next))
     return addUnwrappedLine();
 }
 
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -858,26 +858,44 @@
                "return 1",
                "a = null\n"
                "  return   1");
+  // Below "class Y {}" should ideally be on its own line.
   verifyFormat(
       "x = {\n"
       "  a: 1\n"
-      "}\n"
-      "class Y {}",
+      "} class Y {}",
       "  x  =  {a  : 1}\n"
       "   class  Y {  }");
+  verifyFormat(
+      "if (x) {\n"
+      "}\n"
+      "return 1",
+      "if (x) {}\n"
+      " return   1");
+  verifyFormat(
+      "if (x) {\n"
+      "}\n"
+      "class X {}",
+      "if (x) {}\n"
+      " class X {}");
 }
 
 TEST_F(FormatTestJS, ImportExportASI) {
   verifyFormat(
       "import {x} from 'y'\n"
       "export function z() {}",
       "import   {x} from 'y'\n"
       "  export function z() {}");
+  // Below "class Y {}" should ideally be on its own line.
   verifyFormat(
-      "export {x}\n"
-      "class Y {}",
+      "export {x} class Y {}",
       "  export {x}\n"
       "  class  Y {\n}");
+  verifyFormat(
+      "if (x) {\n"
+      "}\n"
+      "export class Y {}",
+      "if ( x ) { }\n"
+      " export class Y {}");
 }
 
 TEST_F(FormatTestJS, ClosureStyleCasts) {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to