r237244 - clang-format: [ObjC] Further improve wrapping of methods calls without inputs.
Daniel Jasper
djasper at google.com
Wed May 13 03:23:04 PDT 2015
Author: djasper
Date: Wed May 13 05:23:03 2015
New Revision: 237244
URL: http://llvm.org/viewvc/llvm-project?rev=237244&view=rev
Log:
clang-format: [ObjC] Further improve wrapping of methods calls without inputs.
Before:
[aaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaa[aaaaaaaaaaaaaaaaaaaaa] aaaaaaaaaaaaaaaaaaaaaa];
After:
[aaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaa[aaaaaaaaaaaaaaaaaaaaa]
aaaaaaaaaaaaaaaaaaaaaa];
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=237244&r1=237243&r2=237244&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed May 13 05:23:03 2015
@@ -2111,7 +2111,8 @@ bool TokenAnnotator::canBreakBefore(cons
return false;
if (Left.is(tok::colon) && (Left.isOneOf(TT_DictLiteral, TT_ObjCMethodExpr)))
return true;
- if (Right.is(TT_SelectorName))
+ if (Right.is(TT_SelectorName) || (Right.is(tok::identifier) && Right.Next &&
+ Right.Next->is(TT_ObjCMethodExpr)))
return true;
if (Left.is(tok::r_paren) && Line.Type == LT_ObjCProperty)
return true;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=237244&r1=237243&r2=237244&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed May 13 05:23:03 2015
@@ -7299,6 +7299,8 @@ TEST_F(FormatTest, FormatObjCMethodExpr)
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa];");
verifyFormat("[aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaa)\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa];");
+ verifyFormat("[aaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaa[aaaaaaaaaaaaaaaaaaaaa]\n"
+ " aaaaaaaaaaaaaaaaaaaaaa];");
verifyFormat(
"scoped_nsobject<NSTextField> message(\n"
More information about the cfe-commits
mailing list