clang-format: [JS] do not wrap after interface and type.
Summary:
`interface` and `type` are pseudo keywords and cause automatic semicolon
insertion when followed by a line break:
interface // gets parsed as a long variable access to "interface"
VeryLongInterfaceName {
}
With this change, clang-format not longer wraps after `interface` or `type`.
Reviewers: djasper
Subscribers: cfe-commits, klimek
Differential Revision: https://reviews.llvm.org/D30874
llvm-svn: 297605
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index 23253cc..f084467 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -1228,6 +1228,20 @@
"class C {}");
}
+TEST_F(FormatTestJS, TypeInterfaceLineWrapping) {
+ const FormatStyle &Style = getGoogleJSStyleWithColumns(20);
+ verifyFormat("type LongTypeIsReallyUnreasonablyLong =\n"
+ " string;\n",
+ "type LongTypeIsReallyUnreasonablyLong = string;\n",
+ Style);
+ verifyFormat(
+ "interface AbstractStrategyFactoryProvider {\n"
+ " a: number\n"
+ "}\n",
+ "interface AbstractStrategyFactoryProvider { a: number }\n",
+ Style);
+}
+
TEST_F(FormatTestJS, Modules) {
verifyFormat("import SomeThing from 'some/module.js';");
verifyFormat("import {X, Y} from 'some/module.js';");