[PATCH] clang-format: [JS] Do not collapse short interfaces.

Martin Probst martinprobst at google.com
Mon May 4 19:12:18 PDT 2015


Hi djasper,

http://reviews.llvm.org/D9494

Files:
  lib/Format/UnwrappedLineFormatter.cpp
  unittests/Format/FormatTestJS.cpp

Index: lib/Format/UnwrappedLineFormatter.cpp
===================================================================
--- lib/Format/UnwrappedLineFormatter.cpp
+++ lib/Format/UnwrappedLineFormatter.cpp
@@ -239,7 +239,8 @@
     } else if (Limit != 0 && Line.First->isNot(tok::kw_namespace) &&
                !startsExternCBlock(Line)) {
       // We don't merge short records.
-      if (Line.First->isOneOf(tok::kw_class, tok::kw_union, tok::kw_struct))
+      if (Line.First->isOneOf(tok::kw_class, tok::kw_union, tok::kw_struct,
+                              Keywords.kw_interface))
         return 0;
 
       // Check that we still have three lines and they fit into the limit.
Index: unittests/Format/FormatTestJS.cpp
===================================================================
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -547,6 +547,12 @@
   verifyFormat("class C extends p.P implements i.I {}");
 }
 
+TEST_F(FormatTestJS, InterfaceDeclarations) {
+  verifyFormat("interface I {\n"
+               "  x: string;\n"
+               "}");
+}
+
 TEST_F(FormatTestJS, MetadataAnnotations) {
   verifyFormat("@A\nclass C {\n}");
   verifyFormat("@A({arg: 'value'})\nclass C {\n}");
@@ -703,7 +709,9 @@
                "  y?: z;\n"
                "  z?;\n"
                "}");
-  verifyFormat("interface X { y?(): z; }");
+  verifyFormat("interface X {\n"
+               "  y?(): z;\n"
+               "}");
   verifyFormat("x ? 1 : 2;");
 }

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9494.24933.patch
Type: text/x-patch
Size: 1489 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150505/6690e747/attachment.bin>


More information about the cfe-commits mailing list