mirror of
https://github.com/intel/llvm.git
synced 2026-01-30 22:53:05 +08:00
Implement a special code-completion pattern for "IBAction". Fixes
<rdar://problem/8767704>. llvm-svn: 125604
This commit is contained in:
@@ -4984,7 +4984,8 @@ public:
|
||||
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,
|
||||
|
||||
@@ -723,7 +723,7 @@ bool Parser::isTokIdentifier_in() const {
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
@@ -4307,7 +4307,8 @@ void Sema::CodeCompleteObjCPropertySetter(Scope *S, Decl *ObjCImplDecl) {
|
||||
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);
|
||||
@@ -4335,6 +4336,26 @@ void Sema::CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS) {
|
||||
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();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* 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;
|
||||
@@ -158,3 +158,8 @@
|
||||
// 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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user