From: Daniel Jasper Date: Tue, 5 May 2015 08:12:50 +0000 (+0000) Subject: clang-format: [JS] Do not collapse short interfaces. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3d7e6994bba3a8d1747635bc874faf813b4be163;p=clang clang-format: [JS] Do not collapse short interfaces. Patch by Martin Probst. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236485 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/UnwrappedLineFormatter.cpp b/lib/Format/UnwrappedLineFormatter.cpp index 888c69176e..fb1e8dd684 100644 --- a/lib/Format/UnwrappedLineFormatter.cpp +++ b/lib/Format/UnwrappedLineFormatter.cpp @@ -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. diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp index a7d8dd3eff..0c36dce93d 100644 --- a/unittests/Format/FormatTestJS.cpp +++ b/unittests/Format/FormatTestJS.cpp @@ -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}");