Summary:
E.g. don't wrap like this:
(foo.bar.baz).and.bam(Blah.of({
}))
But rather:
(foo.bar.baz)
.and.bam(Blah.of({}))
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D36139
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@309712
91177308-0d34-0410-b5e6-
96231b3b80d8
if ((Left.is(TT_TemplateString) && Left.TokenText.endswith("${")) ||
(Right.is(TT_TemplateString) && Right.TokenText.startswith("}")))
return 100;
+ // Prefer breaking call chains (".foo") over empty "{}", "[]" or "()".
+ if (Left.opensScope() && Right.closesScope())
+ return 200;
}
if (Right.is(tok::identifier) && Right.Next && Right.Next->is(TT_DictLiteral))
}
+TEST_F(FormatTestJS, DontWrapEmptyLiterals) {
+ verifyFormat("(aaaaaaaaaaaaaaaaaaaaa.getData as jasmine.Spy)\n"
+ " .and.returnValue(Observable.of([]));");
+ verifyFormat("(aaaaaaaaaaaaaaaaaaaaa.getData as jasmine.Spy)\n"
+ " .and.returnValue(Observable.of({}));");
+ verifyFormat("(aaaaaaaaaaaaaaaaaaaaa.getData as jasmine.Spy)\n"
+ " .and.returnValue(Observable.of(()));");
+}
+
TEST_F(FormatTestJS, InliningFunctionLiterals) {
FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript);
Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;