summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-05-05 08:12:50 +0000
committerDaniel Jasper <djasper@google.com>2015-05-05 08:12:50 +0000
commit2964749cfad609d4e191af77162db79d8e02fcf6 (patch)
tree6fb328e097344f9ccff59b1a11ff8c55d910f28c
parentda6d5b919d0cce5561f4800a1540cac6938d78b9 (diff)
downloadbcm5719-llvm-2964749cfad609d4e191af77162db79d8e02fcf6.tar.gz
bcm5719-llvm-2964749cfad609d4e191af77162db79d8e02fcf6.zip
clang-format: [JS] Do not collapse short interfaces.
Patch by Martin Probst. llvm-svn: 236485
-rw-r--r--clang/lib/Format/UnwrappedLineFormatter.cpp3
-rw-r--r--clang/unittests/Format/FormatTestJS.cpp6
2 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp b/clang/lib/Format/UnwrappedLineFormatter.cpp
index 888c69176ec..fb1e8dd6842 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/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/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index a7d8dd3effa..0c36dce93dd 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/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}");
OpenPOWER on IntegriCloud