diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-07-08 23:37:41 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-07-08 23:37:41 +0000 |
| commit | 45879695553e4fcf007227eba100d3b4b366d477 (patch) | |
| tree | a3bb49632a452836fa5a51066a4ed5def98bc38e /clang/lib | |
| parent | d08fb75aaa666fad253fd269dbe53c399a35f515 (diff) | |
| download | bcm5719-llvm-45879695553e4fcf007227eba100d3b4b366d477.tar.gz bcm5719-llvm-45879695553e4fcf007227eba100d3b4b366d477.zip | |
Support code completion for parameter names in Objective-C method
declarations.
llvm-svn: 107933
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Parse/ParseObjc.cpp | 15 | ||||
| -rw-r--r-- | clang/lib/Sema/Sema.h | 1 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaCodeComplete.cpp | 15 |
3 files changed, 31 insertions, 0 deletions
diff --git a/clang/lib/Parse/ParseObjc.cpp b/clang/lib/Parse/ParseObjc.cpp index 79e432d6114..68473a551d1 100644 --- a/clang/lib/Parse/ParseObjc.cpp +++ b/clang/lib/Parse/ParseObjc.cpp @@ -856,6 +856,20 @@ Parser::DeclPtrTy Parser::ParseObjCMethodDecl(SourceLocation mLoc, if (getLang().ObjC2 && Tok.is(tok::kw___attribute)) ArgInfo.ArgAttrs = ParseGNUAttributes(); + // Code completion for the next piece of the selector. + if (Tok.is(tok::code_completion)) { + ConsumeCodeCompletionToken(); + KeyIdents.push_back(SelIdent); + Actions.CodeCompleteObjCMethodDeclSelector(getCurScope(), + mType == tok::minus, + /*AtParameterName=*/true, + ReturnType, + KeyIdents.data(), + KeyIdents.size()); + KeyIdents.pop_back(); + break; + } + if (Tok.isNot(tok::identifier)) { Diag(Tok, diag::err_expected_ident); // missing argument name. break; @@ -873,6 +887,7 @@ Parser::DeclPtrTy Parser::ParseObjCMethodDecl(SourceLocation mLoc, ConsumeCodeCompletionToken(); Actions.CodeCompleteObjCMethodDeclSelector(getCurScope(), mType == tok::minus, + /*AtParameterName=*/false, ReturnType, KeyIdents.data(), KeyIdents.size()); diff --git a/clang/lib/Sema/Sema.h b/clang/lib/Sema/Sema.h index f4f873df2f3..1f948b66243 100644 --- a/clang/lib/Sema/Sema.h +++ b/clang/lib/Sema/Sema.h @@ -4574,6 +4574,7 @@ public: DeclPtrTy IDecl); virtual void CodeCompleteObjCMethodDeclSelector(Scope *S, bool IsInstanceMethod, + bool AtParameterName, TypeTy *ReturnType, IdentifierInfo **SelIdents, unsigned NumSelIdents); diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index 8df9eace276..6a706dfefe5 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -4147,6 +4147,7 @@ void Sema::CodeCompleteObjCMethodDecl(Scope *S, void Sema::CodeCompleteObjCMethodDeclSelector(Scope *S, bool IsInstanceMethod, + bool AtParameterName, TypeTy *ReturnTy, IdentifierInfo **SelIdents, unsigned NumSelIdents) { @@ -4185,6 +4186,20 @@ void Sema::CodeCompleteObjCMethodDeclSelector(Scope *S, NumSelIdents)) continue; + if (AtParameterName) { + // Suggest parameter names we've seen before. + if (NumSelIdents && NumSelIdents <= MethList->Method->param_size()) { + ParmVarDecl *Param = MethList->Method->param_begin()[NumSelIdents-1]; + if (Param->getIdentifier()) { + CodeCompletionString *Pattern = new CodeCompletionString; + Pattern->AddTypedTextChunk(Param->getIdentifier()->getName()); + Results.AddResult(Pattern); + } + } + + continue; + } + Result R(MethList->Method, 0); R.StartParameter = NumSelIdents; R.AllParametersAreInformative = false; |

