}
State.Stack.pop_back();
}
- bool IsObjCBlock =
- Previous &&
- (Previous->is(tok::caret) ||
- (Previous->is(tok::r_paren) && Previous->MatchingParen &&
- Previous->MatchingParen->Previous &&
- Previous->MatchingParen->Previous->is(tok::caret)));
// For some reason, ObjC blocks are indented like continuations.
NewIndent =
- State.Stack.back().LastSpace +
- (IsObjCBlock ? Style.ContinuationIndentWidth : Style.IndentWidth);
+ State.Stack.back().LastSpace + (Current.Type == TT_ObjCBlockLBrace
+ ? Style.ContinuationIndentWidth
+ : Style.IndentWidth);
++NewIndentLevel;
BreakBeforeParameter = true;
} else {
bool parseParens(bool LookForDecls = false) {
if (CurrentToken == NULL)
return false;
- bool AfterCaret = Contexts.back().CaretFound;
- Contexts.back().CaretFound = false;
-
ScopedContextCreator ContextCreator(*this, tok::l_paren, 1);
// FIXME: This is a bit of a hack. Do better.
Left->Previous->MatchingParen->Type == TT_LambdaLSquare) {
// This is a parameter list of a lambda expression.
Contexts.back().IsExpression = false;
- } else if (AfterCaret) {
+ } else if (Contexts[Contexts.size() - 2].CaretFound) {
// This is the parameter list of an ObjC block.
Contexts.back().IsExpression = false;
} else if (Left->Previous && Left->Previous->is(tok::kw___attribute)) {
bool parseBrace() {
if (CurrentToken != NULL) {
FormatToken *Left = CurrentToken->Previous;
+
+ if (Contexts.back().CaretFound)
+ Left->Type = TT_ObjCBlockLBrace;
+ Contexts.back().CaretFound = false;
+
ScopedContextCreator ContextCreator(*this, tok::l_brace, 1);
Contexts.back().ColonIsDictLiteral = true;