aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaCodeComplete.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-11-17 16:44:22 +0000
committerDouglas Gregor <dgregor@apple.com>2009-11-17 16:44:22 +0000
commit9630eb6e375c4477d7fd7fd72ddfa64bb6685a03 (patch)
tree7b898f4b5f9d0e0a1e8ae3b0f99a96394b43b1a8 /lib/Sema/SemaCodeComplete.cpp
parent92eff466867fd6a82fb3e245f2091e96a3e9888e (diff)
Augment code-completion results to provide argument names and
placeholder arguments for Objective-C message sends. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89103 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCodeComplete.cpp')
-rw-r--r--lib/Sema/SemaCodeComplete.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp
index de30441c53..e2aac77507 100644
--- a/lib/Sema/SemaCodeComplete.cpp
+++ b/lib/Sema/SemaCodeComplete.cpp
@@ -932,6 +932,39 @@ CodeCompleteConsumer::Result::CreateCodeCompletionString(Sema &S) {
return Result;
}
+ if (ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(ND)) {
+ CodeCompletionString *Result = new CodeCompletionString;
+ Selector Sel = Method->getSelector();
+ if (Sel.isUnarySelector()) {
+ Result->AddTypedTextChunk(Sel.getIdentifierInfoForSlot(0)->getName());
+ return Result;
+ }
+
+ Result->AddTypedTextChunk(
+ Sel.getIdentifierInfoForSlot(0)->getName().str() + std::string(":"));
+ unsigned Idx = 0;
+ for (ObjCMethodDecl::param_iterator P = Method->param_begin(),
+ PEnd = Method->param_end();
+ P != PEnd; (void)++P, ++Idx) {
+ if (Idx > 0) {
+ std::string Keyword = " ";
+ if (IdentifierInfo *II = Sel.getIdentifierInfoForSlot(Idx))
+ Keyword += II->getName().str();
+ Keyword += ":";
+ Result->AddTextChunk(Keyword);
+ }
+
+ std::string Arg;
+ (*P)->getType().getAsStringInternal(Arg, S.Context.PrintingPolicy);
+ Arg = "(" + Arg + ")";
+ if (IdentifierInfo *II = (*P)->getIdentifier())
+ Arg += II->getName().str();
+ Result->AddPlaceholderChunk(Arg);
+ }
+
+ return Result;
+ }
+
if (Qualifier) {
CodeCompletionString *Result = new CodeCompletionString;
AddQualifierToCompletionString(Result, Qualifier, QualifierIsInformative,