clang-format: Lower binding strengths created by the [] created by ObjC
method expressions and array literals. They should not bind stronger
than regular parentheses or the braces of braced lists.
Specific test case in JavaScript:
Before:
var aaaaa: List<
SomeThing> = [new SomeThingAAAAAAAAAAAA(), new SomeThingBBBBBBBBB()];
After:
var aaaaa: List<SomeThing> = [
new SomeThingAAAAAAAAAAAA(),
new SomeThingBBBBBBBBB()
];
llvm-svn: 238400
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 1c100c3..09e514e 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -7585,9 +7585,9 @@
" index:(NSUInteger)index\n"
" nonDigitAttributes:\n"
" (NSDictionary *)noDigitAttributes;");
- verifyFormat(
- "[someFunction someLooooooooooooongParameter:\n"
- " @[ NSBundle.mainBundle.infoDictionary[@\"a\"] ]];");
+ verifyFormat("[someFunction someLooooooooooooongParameter:@[\n"
+ " NSBundle.mainBundle.infoDictionary[@\"a\"]\n"
+ "]];");
}
TEST_F(FormatTest, ReformatRegionAdjustsIndent) {
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index a06daac..a536926 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -239,6 +239,13 @@
"}");
}
+TEST_F(FormatTestJS, ArrayLiterals) {
+ verifyFormat("var aaaaa: List<SomeThing> = [\n"
+ " new SomeThingAAAAAAAAAAAA(),\n"
+ " new SomeThingBBBBBBBBB()\n"
+ "];");
+}
+
TEST_F(FormatTestJS, FunctionLiterals) {
verifyFormat("doFoo(function() {});");
verifyFormat("doFoo(function() { return 1; });");