diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-09-15 16:23:04 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-09-15 16:23:04 +0000 |
commit | 78edf515544f0b9dddf69d6c1678fd83e94d8352 (patch) | |
tree | ebbc3d8638d96124c58b1136d6541d5932efe3c8 /lib/Parse/ParseExpr.cpp | |
parent | 5f81d8aa26ad4de6568772c4768b272af96c18be (diff) |
Improve code completion for Objective-C message sends when the opening
'[' is missing. Prior commits improving recovery also improved code
completion beyond the first selector, e.g., at or after the "to" in
calculator add:x to:y
but not after "calculator". We now provide the same completions for
calculator <CC>
that we would for
[calculator <CC>
if "calculator" is an expression whose type is something that can
receive Objective-C messages.
This code completion works for instance and super message sends, but not
class message sends.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113976 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseExpr.cpp')
-rw-r--r-- | lib/Parse/ParseExpr.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index 0f9154827e..26563de2b2 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -664,12 +664,14 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, } // In an Objective-C method, if we have "super" followed by an identifier, - // the token sequence is ill-fomed. However, if there's a ':' or ']' after + // the token sequence is ill-formed. However, if there's a ':' or ']' after // that identifier, this is probably a message send with a missing open - // bracket. Treat it as such. - if (getLang().ObjC1 && &II == Ident_super && Tok.is(tok::identifier) && + // bracket. Treat it as such. + if (getLang().ObjC1 && &II == Ident_super && !InMessageExpression && getCurScope()->isInObjcMethodScope() && - (NextToken().is(tok::colon) || NextToken().is(tok::r_square))) { + ((Tok.is(tok::identifier) && + (NextToken().is(tok::colon) || NextToken().is(tok::r_square))) || + Tok.is(tok::code_completion))) { Res = ParseObjCMessageExpressionBody(SourceLocation(), ILoc, ParsedType(), 0); break; @@ -991,6 +993,15 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { SourceLocation Loc; while (1) { switch (Tok.getKind()) { + case tok::code_completion: + if (InMessageExpression) + return move(LHS); + + Actions.CodeCompletePostfixExpression(getCurScope(), LHS.take()); + ConsumeCodeCompletionToken(); + LHS = ExprError(); + break; + case tok::identifier: // If we see identifier: after an expression, and we're not already in a // message send, then this is probably a message send with a missing |