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 | 5cec2aea3f5c402bbf570bc71dc173562424c8d6 (patch) | |
tree | 831c0bb13a4db8c277d53fc819130d1abdb188d6 /clang/lib/Parse/Parser.cpp | |
parent | a3deaeeb52acdc863ee98eb5bb20b419518bc592 (diff) | |
download | bcm5719-llvm-5cec2aea3f5c402bbf570bc71dc173562424c8d6.tar.gz bcm5719-llvm-5cec2aea3f5c402bbf570bc71dc173562424c8d6.zip |
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
llvm-svn: 139086
Diffstat (limited to 'clang/lib/Parse/Parser.cpp')
-rw-r--r-- | clang/lib/Parse/Parser.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index f1ca3fadefc..9a26a5a3995 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -553,7 +553,12 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs, ParsingDeclSpec *DS) { DelayedCleanupPoint CleanupRAII(TopLevelDeclCleanupPool); ParenBraceBracketBalancer BalancerRAIIObj(*this); - + + if (PP.isCodeCompletionReached()) { + cutOffParsing(); + return DeclGroupPtrTy(); + } + Decl *SingleDecl = 0; switch (Tok.getKind()) { case tok::semi: @@ -608,8 +613,8 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs, Actions.CodeCompleteOrdinaryName(getCurScope(), ObjCImpDecl? Sema::PCC_ObjCImplementation : Sema::PCC_Namespace); - ConsumeCodeCompletionToken(); - return ParseExternalDeclaration(attrs); + cutOffParsing(); + return DeclGroupPtrTy(); case tok::kw_using: case tok::kw_namespace: case tok::kw_typedef: @@ -1413,20 +1418,27 @@ bool Parser::isTokenEqualOrMistypedEqualEqual(unsigned DiagID) { return Tok.is(tok::equal); } -void Parser::CodeCompletionRecovery() { +SourceLocation Parser::handleUnexpectedCodeCompletionToken() { + assert(Tok.is(tok::code_completion)); + PrevTokLocation = Tok.getLocation(); + for (Scope *S = getCurScope(); S; S = S->getParent()) { if (S->getFlags() & Scope::FnScope) { Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_RecoveryInFunction); - return; + cutOffParsing(); + return PrevTokLocation; } if (S->getFlags() & Scope::ClassScope) { Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Class); - return; + cutOffParsing(); + return PrevTokLocation; } } Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Namespace); + cutOffParsing(); + return PrevTokLocation; } // Anchor the Parser::FieldCallback vtable to this translation unit. |