]> granicus.if.org Git - clang/commitdiff
clang-format: [JS] Do not collapse short interfaces.
authorDaniel Jasper <djasper@google.com>
Tue, 5 May 2015 08:12:50 +0000 (08:12 +0000)
committerDaniel Jasper <djasper@google.com>
Tue, 5 May 2015 08:12:50 +0000 (08:12 +0000)
Patch by Martin Probst.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236485 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 888c69176ec4c5749d6acb99261339a1c35e13d9..fb1e8dd684218616291497b94e9368ff30c11539 100644 (file)
@@ -239,7 +239,8 @@ private:
     } 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 a7d8dd3effa69b784f84e899a1efc5de3c932c16..0c36dce93dd471a0a3ee4b6c4ad53e7f7cc5a347 100644 (file)
@@ -547,6 +547,12 @@ TEST_F(FormatTestJS, ClassDeclarations) {
   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}");