clang-format: [ObjC] Make IndentWrappedFunctionNames work with ObjC functions
llvm-svn: 237241
This commit is contained in:
parent
4276cb3a50
commit
a2a4d9c049
|
@ -421,7 +421,11 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State,
|
||||||
State.Stack.back().AlignColons = false;
|
State.Stack.back().AlignColons = false;
|
||||||
} else {
|
} else {
|
||||||
State.Stack.back().ColonPos =
|
State.Stack.back().ColonPos =
|
||||||
State.Stack.back().Indent + NextNonComment->LongestObjCSelectorName;
|
(Style.IndentWrappedFunctionNames
|
||||||
|
? std::max(State.Stack.back().Indent,
|
||||||
|
State.FirstIndent + Style.ContinuationIndentWidth)
|
||||||
|
: State.Stack.back().Indent) +
|
||||||
|
NextNonComment->LongestObjCSelectorName;
|
||||||
}
|
}
|
||||||
} else if (State.Stack.back().AlignColons &&
|
} else if (State.Stack.back().AlignColons &&
|
||||||
State.Stack.back().ColonPos <= NextNonComment->ColumnWidth) {
|
State.Stack.back().ColonPos <= NextNonComment->ColumnWidth) {
|
||||||
|
@ -572,7 +576,10 @@ unsigned ContinuationIndenter::getNewLineColumn(const LineState &State) {
|
||||||
if (!State.Stack.back().ObjCSelectorNameFound) {
|
if (!State.Stack.back().ObjCSelectorNameFound) {
|
||||||
if (NextNonComment->LongestObjCSelectorName == 0)
|
if (NextNonComment->LongestObjCSelectorName == 0)
|
||||||
return State.Stack.back().Indent;
|
return State.Stack.back().Indent;
|
||||||
return State.Stack.back().Indent +
|
return (Style.IndentWrappedFunctionNames
|
||||||
|
? std::max(State.Stack.back().Indent,
|
||||||
|
State.FirstIndent + Style.ContinuationIndentWidth)
|
||||||
|
: State.Stack.back().Indent) +
|
||||||
NextNonComment->LongestObjCSelectorName -
|
NextNonComment->LongestObjCSelectorName -
|
||||||
NextNonComment->ColumnWidth;
|
NextNonComment->ColumnWidth;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6863,6 +6863,21 @@ TEST_F(FormatTest, FormatForObjectiveCMethodDecls) {
|
||||||
" outRange8:(NSRange)out_range8\n"
|
" outRange8:(NSRange)out_range8\n"
|
||||||
" outRange9:(NSRange)out_range9;");
|
" outRange9:(NSRange)out_range9;");
|
||||||
|
|
||||||
|
// When the function name has to be wrapped.
|
||||||
|
FormatStyle Style = getLLVMStyle();
|
||||||
|
Style.IndentWrappedFunctionNames = false;
|
||||||
|
verifyFormat("- (SomeLooooooooooooooooooooongType *)\n"
|
||||||
|
"veryLooooooooooongName:(NSString)aaaaaaaaaaaaaa\n"
|
||||||
|
" anotherName:(NSString)bbbbbbbbbbbbbb {\n"
|
||||||
|
"}",
|
||||||
|
Style);
|
||||||
|
Style.IndentWrappedFunctionNames = true;
|
||||||
|
verifyFormat("- (SomeLooooooooooooooooooooongType *)\n"
|
||||||
|
" veryLooooooooooongName:(NSString)aaaaaaaaaaaaaa\n"
|
||||||
|
" anotherName:(NSString)bbbbbbbbbbbbbb {\n"
|
||||||
|
"}",
|
||||||
|
Style);
|
||||||
|
|
||||||
verifyFormat("- (int)sum:(vector<int>)numbers;");
|
verifyFormat("- (int)sum:(vector<int>)numbers;");
|
||||||
verifyGoogleFormat("- (void)setDelegate:(id<Protocol>)delegate;");
|
verifyGoogleFormat("- (void)setDelegate:(id<Protocol>)delegate;");
|
||||||
// FIXME: In LLVM style, there should be a space in front of a '<' for ObjC
|
// FIXME: In LLVM style, there should be a space in front of a '<' for ObjC
|
||||||
|
|
Loading…
Reference in New Issue