зеркало из https://github.com/microsoft/clang-1.git
Code completion after @property, providing the names of forward-declared properties
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89196 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
f9a7c18a4d
Коммит
083128f6b1
|
@ -2365,6 +2365,12 @@ public:
|
||||||
/// parsed.
|
/// parsed.
|
||||||
virtual void CodeCompleteObjCProtocolReferences(IdentifierLocPair *Protocols,
|
virtual void CodeCompleteObjCProtocolReferences(IdentifierLocPair *Protocols,
|
||||||
unsigned NumProtocols) { }
|
unsigned NumProtocols) { }
|
||||||
|
|
||||||
|
/// \brief Code completion for a protocol declaration or definition, after
|
||||||
|
/// the @protocol but before any identifier.
|
||||||
|
///
|
||||||
|
/// \param S the scope in which the protocol declaration occurs.
|
||||||
|
virtual void CodeCompleteObjCProtocolDecl(Scope *S) { }
|
||||||
//@}
|
//@}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -994,6 +994,11 @@ Parser::DeclPtrTy Parser::ParseObjCAtProtocolDeclaration(SourceLocation AtLoc,
|
||||||
"ParseObjCAtProtocolDeclaration(): Expected @protocol");
|
"ParseObjCAtProtocolDeclaration(): Expected @protocol");
|
||||||
ConsumeToken(); // the "protocol" identifier
|
ConsumeToken(); // the "protocol" identifier
|
||||||
|
|
||||||
|
if (Tok.is(tok::code_completion)) {
|
||||||
|
Actions.CodeCompleteObjCProtocolDecl(CurScope);
|
||||||
|
ConsumeToken();
|
||||||
|
}
|
||||||
|
|
||||||
if (Tok.isNot(tok::identifier)) {
|
if (Tok.isNot(tok::identifier)) {
|
||||||
Diag(Tok, diag::err_expected_ident); // missing protocol name.
|
Diag(Tok, diag::err_expected_ident); // missing protocol name.
|
||||||
return DeclPtrTy();
|
return DeclPtrTy();
|
||||||
|
|
|
@ -4017,7 +4017,8 @@ public:
|
||||||
virtual void CodeCompleteObjCInstanceMessage(Scope *S, ExprTy *Receiver);
|
virtual void CodeCompleteObjCInstanceMessage(Scope *S, ExprTy *Receiver);
|
||||||
virtual void CodeCompleteObjCProtocolReferences(IdentifierLocPair *Protocols,
|
virtual void CodeCompleteObjCProtocolReferences(IdentifierLocPair *Protocols,
|
||||||
unsigned NumProtocols);
|
unsigned NumProtocols);
|
||||||
//@}
|
virtual void CodeCompleteObjCProtocolDecl(Scope *S);
|
||||||
|
//@}
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// Extra semantic analysis beyond the C type system
|
// Extra semantic analysis beyond the C type system
|
||||||
|
|
|
@ -1830,6 +1830,7 @@ void Sema::CodeCompleteObjCInstanceMessage(Scope *S, ExprTy *Receiver) {
|
||||||
/// \brief Add all of the protocol declarations that we find in the given
|
/// \brief Add all of the protocol declarations that we find in the given
|
||||||
/// (translation unit) context.
|
/// (translation unit) context.
|
||||||
static void AddProtocolResults(DeclContext *Ctx, DeclContext *CurContext,
|
static void AddProtocolResults(DeclContext *Ctx, DeclContext *CurContext,
|
||||||
|
bool OnlyForwardDeclarations,
|
||||||
ResultBuilder &Results) {
|
ResultBuilder &Results) {
|
||||||
typedef CodeCompleteConsumer::Result Result;
|
typedef CodeCompleteConsumer::Result Result;
|
||||||
|
|
||||||
|
@ -1838,7 +1839,8 @@ static void AddProtocolResults(DeclContext *Ctx, DeclContext *CurContext,
|
||||||
D != DEnd; ++D) {
|
D != DEnd; ++D) {
|
||||||
// Record any protocols we find.
|
// Record any protocols we find.
|
||||||
if (ObjCProtocolDecl *Proto = dyn_cast<ObjCProtocolDecl>(*D))
|
if (ObjCProtocolDecl *Proto = dyn_cast<ObjCProtocolDecl>(*D))
|
||||||
Results.MaybeAddResult(Result(Proto, 0), CurContext);
|
if (!OnlyForwardDeclarations || Proto->isForwardDecl())
|
||||||
|
Results.MaybeAddResult(Result(Proto, 0), CurContext);
|
||||||
|
|
||||||
// Record any forward-declared protocols we find.
|
// Record any forward-declared protocols we find.
|
||||||
if (ObjCForwardProtocolDecl *Forward
|
if (ObjCForwardProtocolDecl *Forward
|
||||||
|
@ -1847,7 +1849,8 @@ static void AddProtocolResults(DeclContext *Ctx, DeclContext *CurContext,
|
||||||
P = Forward->protocol_begin(),
|
P = Forward->protocol_begin(),
|
||||||
PEnd = Forward->protocol_end();
|
PEnd = Forward->protocol_end();
|
||||||
P != PEnd; ++P)
|
P != PEnd; ++P)
|
||||||
Results.MaybeAddResult(Result(*P, 0), CurContext);
|
if (!OnlyForwardDeclarations || (*P)->isForwardDecl())
|
||||||
|
Results.MaybeAddResult(Result(*P, 0), CurContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1864,7 +1867,20 @@ void Sema::CodeCompleteObjCProtocolReferences(IdentifierLocPair *Protocols,
|
||||||
Results.Ignore(Protocol);
|
Results.Ignore(Protocol);
|
||||||
|
|
||||||
// Add all protocols.
|
// Add all protocols.
|
||||||
AddProtocolResults(Context.getTranslationUnitDecl(), CurContext, Results);
|
AddProtocolResults(Context.getTranslationUnitDecl(), CurContext, false,
|
||||||
|
Results);
|
||||||
|
|
||||||
|
Results.ExitScope();
|
||||||
|
HandleCodeCompleteResults(this, CodeCompleter, Results.data(),Results.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sema::CodeCompleteObjCProtocolDecl(Scope *) {
|
||||||
|
ResultBuilder Results(*this);
|
||||||
|
Results.EnterNewScope();
|
||||||
|
|
||||||
|
// Add all protocols.
|
||||||
|
AddProtocolResults(Context.getTranslationUnitDecl(), CurContext, true,
|
||||||
|
Results);
|
||||||
|
|
||||||
Results.ExitScope();
|
Results.ExitScope();
|
||||||
HandleCodeCompleteResults(this, CodeCompleter, Results.data(),Results.size());
|
HandleCodeCompleteResults(this, CodeCompleter, Results.data(),Results.size());
|
||||||
|
|
|
@ -8,9 +8,18 @@
|
||||||
|
|
||||||
void f(id<Protocol1,Protocol2>);
|
void f(id<Protocol1,Protocol2>);
|
||||||
|
|
||||||
|
@protocol Protocol0;
|
||||||
|
@protocol NewProtocol
|
||||||
|
{
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
// RUN: c-index-test -code-completion-at=%s:9:11 %s | FileCheck -check-prefix=CHECK-CC1 %s
|
// RUN: c-index-test -code-completion-at=%s:9:11 %s | FileCheck -check-prefix=CHECK-CC1 %s
|
||||||
// CHECK-CC1: ObjCProtocolDecl:{TypedText Protocol1}
|
// CHECK-CC1: ObjCProtocolDecl:{TypedText Protocol1}
|
||||||
// CHECK-CC1: ObjCProtocolDecl:{TypedText Protocol2}
|
// CHECK-CC1: ObjCProtocolDecl:{TypedText Protocol2}
|
||||||
// RUN: c-index-test -code-completion-at=%s:9:21 %s | FileCheck -check-prefix=CHECK-CC2 %s
|
// RUN: c-index-test -code-completion-at=%s:9:21 %s | FileCheck -check-prefix=CHECK-CC2 %s
|
||||||
// CHECK-CC2-NOT: ObjCProtocolDecl:{TypedText Protocol1}
|
// CHECK-CC2-NOT: ObjCProtocolDecl:{TypedText Protocol1}
|
||||||
// CHECK-CC2: ObjCProtocolDecl:{TypedText Protocol2}
|
// CHECK-CC2: ObjCProtocolDecl:{TypedText Protocol2}
|
||||||
|
// RUN: c-index-test -code-completion-at=%s:12:11 %s | FileCheck -check-prefix=CHECK-CC3 %s
|
||||||
|
// CHECK-CC3: ObjCProtocolDecl:{TypedText Protocol0}
|
||||||
|
// CHECK-CC3-NEXT: ObjCProtocolDecl:{TypedText Protocol2}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче