aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseStmt.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-09-04 03:32:15 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-09-04 03:32:15 +0000
commit7d100872341f233c81e1d7b72b40457e62c36862 (patch)
treed3c842889058206c8193e7630f19159ebcaaeab5 /lib/Parse/ParseStmt.cpp
parentc8c97a03eb0fdeb4f5fc9c4dea308ebbf46c2c93 (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/ParseStmt.cpp')
-rw-r--r--lib/Parse/ParseStmt.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp
index df768c9a06..7ad48a1f5d 100644
--- a/lib/Parse/ParseStmt.cpp
+++ b/lib/Parse/ParseStmt.cpp
@@ -100,8 +100,8 @@ Retry:
case tok::code_completion:
Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Statement);
- ConsumeCodeCompletionToken();
- return ParseStatementOrDeclaration(Stmts, OnlyStatement);
+ cutOffParsing();
+ return StmtError();
case tok::identifier: {
Token Next = NextToken();
@@ -507,7 +507,8 @@ StmtResult Parser::ParseCaseStatement(ParsedAttributes &attrs, bool MissingCase,
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteCase(getCurScope());
- ConsumeCodeCompletionToken();
+ cutOffParsing();
+ return StmtError();
}
/// We don't want to treat 'case x : y' as a potential typo for 'case x::y'.
@@ -953,7 +954,8 @@ StmtResult Parser::ParseIfStatement(ParsedAttributes &attrs) {
InnerScope.Exit();
} else if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteAfterIf(getCurScope());
- ConsumeCodeCompletionToken();
+ cutOffParsing();
+ return StmtError();
}
IfScope.Exit();
@@ -1282,7 +1284,8 @@ StmtResult Parser::ParseForStatement(ParsedAttributes &attrs) {
Actions.CodeCompleteOrdinaryName(getCurScope(),
C99orCXXorObjC? Sema::PCC_ForInit
: Sema::PCC_Expression);
- ConsumeCodeCompletionToken();
+ cutOffParsing();
+ return StmtError();
}
// Parse the first part of the for specifier.
@@ -1320,7 +1323,8 @@ StmtResult Parser::ParseForStatement(ParsedAttributes &attrs) {
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteObjCForCollection(getCurScope(), DG);
- ConsumeCodeCompletionToken();
+ cutOffParsing();
+ return StmtError();
}
Collection = ParseExpression();
} else {
@@ -1346,7 +1350,8 @@ StmtResult Parser::ParseForStatement(ParsedAttributes &attrs) {
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteObjCForCollection(getCurScope(), DeclGroupPtrTy());
- ConsumeCodeCompletionToken();
+ cutOffParsing();
+ return StmtError();
}
Collection = ParseExpression();
} else {
@@ -1537,8 +1542,7 @@ StmtResult Parser::ParseReturnStatement(ParsedAttributes &attrs) {
if (Tok.isNot(tok::semi)) {
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteReturn(getCurScope());
- ConsumeCodeCompletionToken();
- SkipUntil(tok::semi, false, true);
+ cutOffParsing();
return StmtError();
}