diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-09-04 03:32:15 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-09-04 03:32:15 +0000 |
commit | 7d100872341f233c81e1d7b72b40457e62c36862 (patch) | |
tree | d3c842889058206c8193e7630f19159ebcaaeab5 /lib/Parse/ParseExpr.cpp | |
parent | c8c97a03eb0fdeb4f5fc9c4dea308ebbf46c2c93 (diff) |
Support code-completion for C++ inline methods and ObjC buffering methods.
Previously we would cut off the source file buffer at the code-completion
point; this impeded code-completion inside C++ inline methods and,
recently, with buffering ObjC methods.
Have the code-completion inserted into the source buffer so that it can
be buffered along with a method body. When we actually hit the code-completion
point the cut-off lexing or parsing.
Fixes rdar://10056932&8319466
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139086 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseExpr.cpp')
-rw-r--r-- | lib/Parse/ParseExpr.cpp | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index 42d56c3693..b11bccdf89 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -214,7 +214,8 @@ Parser::ParseExpressionWithLeadingExtension(SourceLocation ExtLoc) { ExprResult Parser::ParseAssignmentExpression() { if (Tok.is(tok::code_completion)) { Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Expression); - ConsumeCodeCompletionToken(); + cutOffParsing(); + return ExprError(); } if (Tok.is(tok::kw_throw)) @@ -336,7 +337,7 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, prec::Level MinPrec) { // goes through a special hook that takes the left-hand side into account. if (Tok.is(tok::code_completion) && NextTokPrec == prec::Assignment) { Actions.CodeCompleteAssignmentRHS(getCurScope(), LHS.get()); - ConsumeCodeCompletionToken(); + cutOffParsing(); return ExprError(); } @@ -1110,9 +1111,8 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, break; case tok::code_completion: { Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Expression); - ConsumeCodeCompletionToken(); - return ParseCastExpression(isUnaryExpression, isAddressOfOperand, - NotCastExpr, isTypeCast); + cutOffParsing(); + return ExprError(); } case tok::l_square: if (getLang().CPlusPlus0x) { @@ -1170,9 +1170,8 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { return move(LHS); Actions.CodeCompletePostfixExpression(getCurScope(), LHS); - ConsumeCodeCompletionToken(); - LHS = ExprError(); - break; + cutOffParsing(); + return ExprError(); case tok::identifier: // If we see identifier: after an expression, and we're not already in a @@ -1272,7 +1271,8 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { if (Tok.is(tok::code_completion)) { Actions.CodeCompleteCall(getCurScope(), LHS.get(), 0, 0); - ConsumeCodeCompletionToken(); + cutOffParsing(); + return ExprError(); } if (OpKind == tok::l_paren || !LHS.isInvalid()) { @@ -1330,7 +1330,8 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { Actions.CodeCompleteMemberReferenceExpr(getCurScope(), LHS.get(), OpLoc, OpKind == tok::arrow); - ConsumeCodeCompletionToken(); + cutOffParsing(); + return ExprError(); } if (MayBePseudoDestructor && !LHS.isInvalid()) { @@ -1778,7 +1779,7 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr, Actions.CodeCompleteOrdinaryName(getCurScope(), ExprType >= CompoundLiteral? Sema::PCC_ParenthesizedExpression : Sema::PCC_Expression); - ConsumeCodeCompletionToken(); + cutOffParsing(); return ExprError(); } @@ -2133,7 +2134,8 @@ bool Parser::ParseExpressionList(SmallVectorImpl<Expr*> &Exprs, (Actions.*Completer)(getCurScope(), Data, Exprs.data(), Exprs.size()); else Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Expression); - ConsumeCodeCompletionToken(); + cutOffParsing(); + return true; } ExprResult Expr; @@ -2164,7 +2166,7 @@ bool Parser::ParseExpressionList(SmallVectorImpl<Expr*> &Exprs, void Parser::ParseBlockId() { if (Tok.is(tok::code_completion)) { Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Type); - ConsumeCodeCompletionToken(); + return cutOffParsing(); } // Parse the specifier-qualifier-list piece. |