void CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS);
void CodeCompleteObjCPropertyGetter(Scope *S, Decl *ClassDecl);
void CodeCompleteObjCPropertySetter(Scope *S, Decl *ClassDecl);
- void CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS);
+ void CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS,
+ bool IsParameter);
void CodeCompleteObjCMessageReceiver(Scope *S);
void CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc,
IdentifierInfo **SelIdents,
void Parser::ParseObjCTypeQualifierList(ObjCDeclSpec &DS, bool IsParameter) {
while (1) {
if (Tok.is(tok::code_completion)) {
- Actions.CodeCompleteObjCPassingType(getCurScope(), DS);
+ Actions.CodeCompleteObjCPassingType(getCurScope(), DS, IsParameter);
ConsumeCodeCompletionToken();
}
Results.data(),Results.size());
}
-void Sema::CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS) {
+void Sema::CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS,
+ bool IsParameter) {
typedef CodeCompletionResult Result;
ResultBuilder Results(*this, CodeCompleter->getAllocator(),
CodeCompletionContext::CCC_Type);
Results.AddResult("oneway");
}
+ // If we're completing the return type of an Objective-C method and the
+ // identifier IBAction refers to a macro, provide a completion item for
+ // an action, e.g.,
+ // IBAction)<#selector#>:(id)sender
+ if (DS.getObjCDeclQualifier() == 0 && !IsParameter &&
+ Context.Idents.get("IBAction").hasMacroDefinition()) {
+ typedef CodeCompletionString::Chunk Chunk;
+ CodeCompletionBuilder Builder(Results.getAllocator(), CCP_CodePattern,
+ CXAvailability_Available);
+ Builder.AddTypedTextChunk("IBAction");
+ Builder.AddChunk(Chunk(CodeCompletionString::CK_RightParen));
+ Builder.AddPlaceholderChunk("selector");
+ Builder.AddChunk(Chunk(CodeCompletionString::CK_Colon));
+ Builder.AddChunk(Chunk(CodeCompletionString::CK_LeftParen));
+ Builder.AddTextChunk("id");
+ Builder.AddChunk(Chunk(CodeCompletionString::CK_RightParen));
+ Builder.AddTextChunk("sender");
+ Results.AddResult(CodeCompletionResult(Builder.TakeString()));
+ }
+
// Add various builtin type names and specifiers.
AddOrdinaryNameResults(PCC_Type, S, *this, Results);
Results.ExitScope();
/* Note: the RUN lines are near the end of the file, since line/column
matter for this test. */
-
+#define IBAction void
@protocol P1
- (id)abc;
- (id)initWithInt:(int)x;
// CHECK-CCH: NotImplemented:{TypedText unsigned} (50)
// CHECK-CCH: NotImplemented:{TypedText void} (50)
// CHECK-CCH: NotImplemented:{TypedText volatile} (50)
+
+// IBAction completion
+// RUN: c-index-test -code-completion-at=%s:5:4 %s | FileCheck -check-prefix=CHECK-IBACTION %s
+// CHECK-IBACTION: NotImplemented:{TypedText IBAction}{RightParen )}{Placeholder selector}{Colon :}{LeftParen (}{Text id}{RightParen )}{Text sender} (40)
+