Support code completion for parameter names in Objective-C method
declarations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107933 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index f4f873d..1f948b6 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -4574,6 +4574,7 @@
DeclPtrTy IDecl);
virtual void CodeCompleteObjCMethodDeclSelector(Scope *S,
bool IsInstanceMethod,
+ bool AtParameterName,
TypeTy *ReturnType,
IdentifierInfo **SelIdents,
unsigned NumSelIdents);
diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp
index 8df9eac..6a706df 100644
--- a/lib/Sema/SemaCodeComplete.cpp
+++ b/lib/Sema/SemaCodeComplete.cpp
@@ -4147,6 +4147,7 @@
void Sema::CodeCompleteObjCMethodDeclSelector(Scope *S,
bool IsInstanceMethod,
+ bool AtParameterName,
TypeTy *ReturnTy,
IdentifierInfo **SelIdents,
unsigned NumSelIdents) {
@@ -4185,6 +4186,20 @@
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;