|
@@ -3303,8 +3303,7 @@ void Sema::CodeCompleteOrdinaryName(Scope *S,
|
|
|
|
|
|
static void AddClassMessageCompletions(Sema &SemaRef, Scope *S,
|
|
static void AddClassMessageCompletions(Sema &SemaRef, Scope *S,
|
|
ParsedType Receiver,
|
|
ParsedType Receiver,
|
|
- IdentifierInfo **SelIdents,
|
|
|
|
- unsigned NumSelIdents,
|
|
|
|
|
|
+ ArrayRef<IdentifierInfo *> SelIdents,
|
|
bool AtArgumentExpression,
|
|
bool AtArgumentExpression,
|
|
bool IsSuper,
|
|
bool IsSuper,
|
|
ResultBuilder &Results);
|
|
ResultBuilder &Results);
|
|
@@ -3360,7 +3359,7 @@ void Sema::CodeCompleteDeclSpec(Scope *S, DeclSpec &DS,
|
|
Scope::AtCatchScope)) == 0) {
|
|
Scope::AtCatchScope)) == 0) {
|
|
ParsedType T = DS.getRepAsType();
|
|
ParsedType T = DS.getRepAsType();
|
|
if (!T.get().isNull() && T.get()->isObjCObjectOrInterfaceType())
|
|
if (!T.get().isNull() && T.get()->isObjCObjectOrInterfaceType())
|
|
- AddClassMessageCompletions(*this, S, T, 0, 0, false, false, Results);
|
|
|
|
|
|
+ AddClassMessageCompletions(*this, S, T, None, false, false, Results);
|
|
}
|
|
}
|
|
|
|
|
|
// Note that we intentionally suppress macro results here, since we do not
|
|
// Note that we intentionally suppress macro results here, since we do not
|
|
@@ -3436,7 +3435,7 @@ void Sema::CodeCompletePostfixExpression(Scope *S, ExprResult E) {
|
|
if (E.isInvalid())
|
|
if (E.isInvalid())
|
|
CodeCompleteOrdinaryName(S, PCC_RecoveryInFunction);
|
|
CodeCompleteOrdinaryName(S, PCC_RecoveryInFunction);
|
|
else if (getLangOpts().ObjC1)
|
|
else if (getLangOpts().ObjC1)
|
|
- CodeCompleteObjCInstanceMessage(S, E.take(), 0, 0, false);
|
|
|
|
|
|
+ CodeCompleteObjCInstanceMessage(S, E.take(), None, false);
|
|
}
|
|
}
|
|
|
|
|
|
/// \brief The set of properties that have already been added, referenced by
|
|
/// \brief The set of properties that have already been added, referenced by
|
|
@@ -4786,9 +4785,9 @@ enum ObjCMethodKind {
|
|
|
|
|
|
static bool isAcceptableObjCSelector(Selector Sel,
|
|
static bool isAcceptableObjCSelector(Selector Sel,
|
|
ObjCMethodKind WantKind,
|
|
ObjCMethodKind WantKind,
|
|
- IdentifierInfo **SelIdents,
|
|
|
|
- unsigned NumSelIdents,
|
|
|
|
|
|
+ ArrayRef<IdentifierInfo *> SelIdents,
|
|
bool AllowSameLength = true) {
|
|
bool AllowSameLength = true) {
|
|
|
|
+ unsigned NumSelIdents = SelIdents.size();
|
|
if (NumSelIdents > Sel.getNumArgs())
|
|
if (NumSelIdents > Sel.getNumArgs())
|
|
return false;
|
|
return false;
|
|
|
|
|
|
@@ -4810,11 +4809,10 @@ static bool isAcceptableObjCSelector(Selector Sel,
|
|
|
|
|
|
static bool isAcceptableObjCMethod(ObjCMethodDecl *Method,
|
|
static bool isAcceptableObjCMethod(ObjCMethodDecl *Method,
|
|
ObjCMethodKind WantKind,
|
|
ObjCMethodKind WantKind,
|
|
- IdentifierInfo **SelIdents,
|
|
|
|
- unsigned NumSelIdents,
|
|
|
|
|
|
+ ArrayRef<IdentifierInfo *> SelIdents,
|
|
bool AllowSameLength = true) {
|
|
bool AllowSameLength = true) {
|
|
return isAcceptableObjCSelector(Method->getSelector(), WantKind, SelIdents,
|
|
return isAcceptableObjCSelector(Method->getSelector(), WantKind, SelIdents,
|
|
- NumSelIdents, AllowSameLength);
|
|
|
|
|
|
+ AllowSameLength);
|
|
}
|
|
}
|
|
|
|
|
|
namespace {
|
|
namespace {
|
|
@@ -4846,8 +4844,7 @@ namespace {
|
|
static void AddObjCMethods(ObjCContainerDecl *Container,
|
|
static void AddObjCMethods(ObjCContainerDecl *Container,
|
|
bool WantInstanceMethods,
|
|
bool WantInstanceMethods,
|
|
ObjCMethodKind WantKind,
|
|
ObjCMethodKind WantKind,
|
|
- IdentifierInfo **SelIdents,
|
|
|
|
- unsigned NumSelIdents,
|
|
|
|
|
|
+ ArrayRef<IdentifierInfo *> SelIdents,
|
|
DeclContext *CurContext,
|
|
DeclContext *CurContext,
|
|
VisitedSelectorSet &Selectors,
|
|
VisitedSelectorSet &Selectors,
|
|
bool AllowSameLength,
|
|
bool AllowSameLength,
|
|
@@ -4866,15 +4863,14 @@ static void AddObjCMethods(ObjCContainerDecl *Container,
|
|
(isRootClass && !WantInstanceMethods)) {
|
|
(isRootClass && !WantInstanceMethods)) {
|
|
// Check whether the selector identifiers we've been given are a
|
|
// Check whether the selector identifiers we've been given are a
|
|
// subset of the identifiers for this particular method.
|
|
// subset of the identifiers for this particular method.
|
|
- if (!isAcceptableObjCMethod(*M, WantKind, SelIdents, NumSelIdents,
|
|
|
|
- AllowSameLength))
|
|
|
|
|
|
+ if (!isAcceptableObjCMethod(*M, WantKind, SelIdents, AllowSameLength))
|
|
continue;
|
|
continue;
|
|
|
|
|
|
if (!Selectors.insert(M->getSelector()))
|
|
if (!Selectors.insert(M->getSelector()))
|
|
continue;
|
|
continue;
|
|
|
|
|
|
Result R = Result(*M, Results.getBasePriority(*M), 0);
|
|
Result R = Result(*M, Results.getBasePriority(*M), 0);
|
|
- R.StartParameter = NumSelIdents;
|
|
|
|
|
|
+ R.StartParameter = SelIdents.size();
|
|
R.AllParametersAreInformative = (WantKind != MK_Any);
|
|
R.AllParametersAreInformative = (WantKind != MK_Any);
|
|
if (!InOriginalClass)
|
|
if (!InOriginalClass)
|
|
R.Priority += CCD_InBaseClass;
|
|
R.Priority += CCD_InBaseClass;
|
|
@@ -4891,8 +4887,7 @@ static void AddObjCMethods(ObjCContainerDecl *Container,
|
|
E = Protocols.end();
|
|
E = Protocols.end();
|
|
I != E; ++I)
|
|
I != E; ++I)
|
|
AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents,
|
|
AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents,
|
|
- NumSelIdents, CurContext, Selectors, AllowSameLength,
|
|
|
|
- Results, false);
|
|
|
|
|
|
+ CurContext, Selectors, AllowSameLength, Results, false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -4903,7 +4898,7 @@ static void AddObjCMethods(ObjCContainerDecl *Container,
|
|
for (ObjCInterfaceDecl::protocol_iterator I = IFace->protocol_begin(),
|
|
for (ObjCInterfaceDecl::protocol_iterator I = IFace->protocol_begin(),
|
|
E = IFace->protocol_end();
|
|
E = IFace->protocol_end();
|
|
I != E; ++I)
|
|
I != E; ++I)
|
|
- AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, NumSelIdents,
|
|
|
|
|
|
+ AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents,
|
|
CurContext, Selectors, AllowSameLength, Results, false);
|
|
CurContext, Selectors, AllowSameLength, Results, false);
|
|
|
|
|
|
// Add methods in categories.
|
|
// Add methods in categories.
|
|
@@ -4914,7 +4909,7 @@ static void AddObjCMethods(ObjCContainerDecl *Container,
|
|
ObjCCategoryDecl *CatDecl = *Cat;
|
|
ObjCCategoryDecl *CatDecl = *Cat;
|
|
|
|
|
|
AddObjCMethods(CatDecl, WantInstanceMethods, WantKind, SelIdents,
|
|
AddObjCMethods(CatDecl, WantInstanceMethods, WantKind, SelIdents,
|
|
- NumSelIdents, CurContext, Selectors, AllowSameLength,
|
|
|
|
|
|
+ CurContext, Selectors, AllowSameLength,
|
|
Results, InOriginalClass);
|
|
Results, InOriginalClass);
|
|
|
|
|
|
// Add a categories protocol methods.
|
|
// Add a categories protocol methods.
|
|
@@ -4924,26 +4919,26 @@ static void AddObjCMethods(ObjCContainerDecl *Container,
|
|
E = Protocols.end();
|
|
E = Protocols.end();
|
|
I != E; ++I)
|
|
I != E; ++I)
|
|
AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents,
|
|
AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents,
|
|
- NumSelIdents, CurContext, Selectors, AllowSameLength,
|
|
|
|
|
|
+ CurContext, Selectors, AllowSameLength,
|
|
Results, false);
|
|
Results, false);
|
|
|
|
|
|
// Add methods in category implementations.
|
|
// Add methods in category implementations.
|
|
if (ObjCCategoryImplDecl *Impl = CatDecl->getImplementation())
|
|
if (ObjCCategoryImplDecl *Impl = CatDecl->getImplementation())
|
|
AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents,
|
|
AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents,
|
|
- NumSelIdents, CurContext, Selectors, AllowSameLength,
|
|
|
|
|
|
+ CurContext, Selectors, AllowSameLength,
|
|
Results, InOriginalClass);
|
|
Results, InOriginalClass);
|
|
}
|
|
}
|
|
|
|
|
|
// Add methods in superclass.
|
|
// Add methods in superclass.
|
|
if (IFace->getSuperClass())
|
|
if (IFace->getSuperClass())
|
|
AddObjCMethods(IFace->getSuperClass(), WantInstanceMethods, WantKind,
|
|
AddObjCMethods(IFace->getSuperClass(), WantInstanceMethods, WantKind,
|
|
- SelIdents, NumSelIdents, CurContext, Selectors,
|
|
|
|
|
|
+ SelIdents, CurContext, Selectors,
|
|
AllowSameLength, Results, false);
|
|
AllowSameLength, Results, false);
|
|
|
|
|
|
// Add methods in our implementation, if any.
|
|
// Add methods in our implementation, if any.
|
|
if (ObjCImplementationDecl *Impl = IFace->getImplementation())
|
|
if (ObjCImplementationDecl *Impl = IFace->getImplementation())
|
|
AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents,
|
|
AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents,
|
|
- NumSelIdents, CurContext, Selectors, AllowSameLength,
|
|
|
|
|
|
+ CurContext, Selectors, AllowSameLength,
|
|
Results, InOriginalClass);
|
|
Results, InOriginalClass);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -4967,7 +4962,7 @@ void Sema::CodeCompleteObjCPropertyGetter(Scope *S) {
|
|
Results.EnterNewScope();
|
|
Results.EnterNewScope();
|
|
|
|
|
|
VisitedSelectorSet Selectors;
|
|
VisitedSelectorSet Selectors;
|
|
- AddObjCMethods(Class, true, MK_ZeroArgSelector, 0, 0, CurContext, Selectors,
|
|
|
|
|
|
+ AddObjCMethods(Class, true, MK_ZeroArgSelector, None, CurContext, Selectors,
|
|
/*AllowSameLength=*/true, Results);
|
|
/*AllowSameLength=*/true, Results);
|
|
Results.ExitScope();
|
|
Results.ExitScope();
|
|
HandleCodeCompleteResults(this, CodeCompleter,
|
|
HandleCodeCompleteResults(this, CodeCompleter,
|
|
@@ -4995,7 +4990,7 @@ void Sema::CodeCompleteObjCPropertySetter(Scope *S) {
|
|
Results.EnterNewScope();
|
|
Results.EnterNewScope();
|
|
|
|
|
|
VisitedSelectorSet Selectors;
|
|
VisitedSelectorSet Selectors;
|
|
- AddObjCMethods(Class, true, MK_OneArgSelector, 0, 0, CurContext,
|
|
|
|
|
|
+ AddObjCMethods(Class, true, MK_OneArgSelector, None, CurContext,
|
|
Selectors, /*AllowSameLength=*/true, Results);
|
|
Selectors, /*AllowSameLength=*/true, Results);
|
|
|
|
|
|
Results.ExitScope();
|
|
Results.ExitScope();
|
|
@@ -5159,16 +5154,14 @@ static ObjCInterfaceDecl *GetAssumedMessageSendExprType(Expr *E) {
|
|
/// \param SelIdents The identifiers in the selector that have already been
|
|
/// \param SelIdents The identifiers in the selector that have already been
|
|
/// provided as arguments for a send to "super".
|
|
/// provided as arguments for a send to "super".
|
|
///
|
|
///
|
|
-/// \param NumSelIdents The number of identifiers in \p SelIdents.
|
|
|
|
-///
|
|
|
|
/// \param Results The set of results to augment.
|
|
/// \param Results The set of results to augment.
|
|
///
|
|
///
|
|
/// \returns the Objective-C method declaration that would be invoked by
|
|
/// \returns the Objective-C method declaration that would be invoked by
|
|
/// this "super" completion. If NULL, no completion was added.
|
|
/// this "super" completion. If NULL, no completion was added.
|
|
-static ObjCMethodDecl *AddSuperSendCompletion(Sema &S, bool NeedSuperKeyword,
|
|
|
|
- IdentifierInfo **SelIdents,
|
|
|
|
- unsigned NumSelIdents,
|
|
|
|
- ResultBuilder &Results) {
|
|
|
|
|
|
+static ObjCMethodDecl *AddSuperSendCompletion(
|
|
|
|
+ Sema &S, bool NeedSuperKeyword,
|
|
|
|
+ ArrayRef<IdentifierInfo *> SelIdents,
|
|
|
|
+ ResultBuilder &Results) {
|
|
ObjCMethodDecl *CurMethod = S.getCurMethodDecl();
|
|
ObjCMethodDecl *CurMethod = S.getCurMethodDecl();
|
|
if (!CurMethod)
|
|
if (!CurMethod)
|
|
return 0;
|
|
return 0;
|
|
@@ -5244,14 +5237,14 @@ static ObjCMethodDecl *AddSuperSendCompletion(Sema &S, bool NeedSuperKeyword,
|
|
} else {
|
|
} else {
|
|
ObjCMethodDecl::param_iterator CurP = CurMethod->param_begin();
|
|
ObjCMethodDecl::param_iterator CurP = CurMethod->param_begin();
|
|
for (unsigned I = 0, N = Sel.getNumArgs(); I != N; ++I, ++CurP) {
|
|
for (unsigned I = 0, N = Sel.getNumArgs(); I != N; ++I, ++CurP) {
|
|
- if (I > NumSelIdents)
|
|
|
|
|
|
+ if (I > SelIdents.size())
|
|
Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
|
|
Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
|
|
|
|
|
|
- if (I < NumSelIdents)
|
|
|
|
|
|
+ if (I < SelIdents.size())
|
|
Builder.AddInformativeChunk(
|
|
Builder.AddInformativeChunk(
|
|
Builder.getAllocator().CopyString(
|
|
Builder.getAllocator().CopyString(
|
|
Sel.getNameForSlot(I) + ":"));
|
|
Sel.getNameForSlot(I) + ":"));
|
|
- else if (NeedSuperKeyword || I > NumSelIdents) {
|
|
|
|
|
|
+ else if (NeedSuperKeyword || I > SelIdents.size()) {
|
|
Builder.AddTextChunk(
|
|
Builder.AddTextChunk(
|
|
Builder.getAllocator().CopyString(
|
|
Builder.getAllocator().CopyString(
|
|
Sel.getNameForSlot(I) + ":"));
|
|
Sel.getNameForSlot(I) + ":"));
|
|
@@ -5293,7 +5286,7 @@ void Sema::CodeCompleteObjCMessageReceiver(Scope *S) {
|
|
if (Iface->getSuperClass()) {
|
|
if (Iface->getSuperClass()) {
|
|
Results.AddResult(Result("super"));
|
|
Results.AddResult(Result("super"));
|
|
|
|
|
|
- AddSuperSendCompletion(*this, /*NeedSuperKeyword=*/true, 0, 0, Results);
|
|
|
|
|
|
+ AddSuperSendCompletion(*this, /*NeedSuperKeyword=*/true, None, Results);
|
|
}
|
|
}
|
|
|
|
|
|
if (getLangOpts().CPlusPlus11)
|
|
if (getLangOpts().CPlusPlus11)
|
|
@@ -5309,8 +5302,7 @@ void Sema::CodeCompleteObjCMessageReceiver(Scope *S) {
|
|
}
|
|
}
|
|
|
|
|
|
void Sema::CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc,
|
|
void Sema::CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc,
|
|
- IdentifierInfo **SelIdents,
|
|
|
|
- unsigned NumSelIdents,
|
|
|
|
|
|
+ ArrayRef<IdentifierInfo *> SelIdents,
|
|
bool AtArgumentExpression) {
|
|
bool AtArgumentExpression) {
|
|
ObjCInterfaceDecl *CDecl = 0;
|
|
ObjCInterfaceDecl *CDecl = 0;
|
|
if (ObjCMethodDecl *CurMethod = getCurMethodDecl()) {
|
|
if (ObjCMethodDecl *CurMethod = getCurMethodDecl()) {
|
|
@@ -5328,8 +5320,7 @@ void Sema::CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc,
|
|
// We are inside an instance method, which means that the message
|
|
// We are inside an instance method, which means that the message
|
|
// send [super ...] is actually calling an instance method on the
|
|
// send [super ...] is actually calling an instance method on the
|
|
// current object.
|
|
// current object.
|
|
- return CodeCompleteObjCInstanceMessage(S, 0,
|
|
|
|
- SelIdents, NumSelIdents,
|
|
|
|
|
|
+ return CodeCompleteObjCInstanceMessage(S, 0, SelIdents,
|
|
AtArgumentExpression,
|
|
AtArgumentExpression,
|
|
CDecl);
|
|
CDecl);
|
|
}
|
|
}
|
|
@@ -5358,7 +5349,7 @@ void Sema::CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc,
|
|
ExprResult SuperExpr = ActOnIdExpression(S, SS, TemplateKWLoc, id,
|
|
ExprResult SuperExpr = ActOnIdExpression(S, SS, TemplateKWLoc, id,
|
|
false, false);
|
|
false, false);
|
|
return CodeCompleteObjCInstanceMessage(S, (Expr *)SuperExpr.get(),
|
|
return CodeCompleteObjCInstanceMessage(S, (Expr *)SuperExpr.get(),
|
|
- SelIdents, NumSelIdents,
|
|
|
|
|
|
+ SelIdents,
|
|
AtArgumentExpression);
|
|
AtArgumentExpression);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -5369,7 +5360,7 @@ void Sema::CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc,
|
|
if (CDecl)
|
|
if (CDecl)
|
|
Receiver = ParsedType::make(Context.getObjCInterfaceType(CDecl));
|
|
Receiver = ParsedType::make(Context.getObjCInterfaceType(CDecl));
|
|
return CodeCompleteObjCClassMessage(S, Receiver, SelIdents,
|
|
return CodeCompleteObjCClassMessage(S, Receiver, SelIdents,
|
|
- NumSelIdents, AtArgumentExpression,
|
|
|
|
|
|
+ AtArgumentExpression,
|
|
/*IsSuper=*/true);
|
|
/*IsSuper=*/true);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -5409,8 +5400,7 @@ static QualType getPreferredArgumentTypeForMessageSend(ResultBuilder &Results,
|
|
|
|
|
|
static void AddClassMessageCompletions(Sema &SemaRef, Scope *S,
|
|
static void AddClassMessageCompletions(Sema &SemaRef, Scope *S,
|
|
ParsedType Receiver,
|
|
ParsedType Receiver,
|
|
- IdentifierInfo **SelIdents,
|
|
|
|
- unsigned NumSelIdents,
|
|
|
|
|
|
+ ArrayRef<IdentifierInfo *> SelIdents,
|
|
bool AtArgumentExpression,
|
|
bool AtArgumentExpression,
|
|
bool IsSuper,
|
|
bool IsSuper,
|
|
ResultBuilder &Results) {
|
|
ResultBuilder &Results) {
|
|
@@ -5434,8 +5424,7 @@ static void AddClassMessageCompletions(Sema &SemaRef, Scope *S,
|
|
// completion.
|
|
// completion.
|
|
if (IsSuper) {
|
|
if (IsSuper) {
|
|
if (ObjCMethodDecl *SuperMethod
|
|
if (ObjCMethodDecl *SuperMethod
|
|
- = AddSuperSendCompletion(SemaRef, false, SelIdents, NumSelIdents,
|
|
|
|
- Results))
|
|
|
|
|
|
+ = AddSuperSendCompletion(SemaRef, false, SelIdents, Results))
|
|
Results.Ignore(SuperMethod);
|
|
Results.Ignore(SuperMethod);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -5446,7 +5435,7 @@ static void AddClassMessageCompletions(Sema &SemaRef, Scope *S,
|
|
|
|
|
|
VisitedSelectorSet Selectors;
|
|
VisitedSelectorSet Selectors;
|
|
if (CDecl)
|
|
if (CDecl)
|
|
- AddObjCMethods(CDecl, false, MK_Any, SelIdents, NumSelIdents,
|
|
|
|
|
|
+ AddObjCMethods(CDecl, false, MK_Any, SelIdents,
|
|
SemaRef.CurContext, Selectors, AtArgumentExpression,
|
|
SemaRef.CurContext, Selectors, AtArgumentExpression,
|
|
Results);
|
|
Results);
|
|
else {
|
|
else {
|
|
@@ -5472,12 +5461,11 @@ static void AddClassMessageCompletions(Sema &SemaRef, Scope *S,
|
|
for (ObjCMethodList *MethList = &M->second.second;
|
|
for (ObjCMethodList *MethList = &M->second.second;
|
|
MethList && MethList->Method;
|
|
MethList && MethList->Method;
|
|
MethList = MethList->getNext()) {
|
|
MethList = MethList->getNext()) {
|
|
- if (!isAcceptableObjCMethod(MethList->Method, MK_Any, SelIdents,
|
|
|
|
- NumSelIdents))
|
|
|
|
|
|
+ if (!isAcceptableObjCMethod(MethList->Method, MK_Any, SelIdents))
|
|
continue;
|
|
continue;
|
|
|
|
|
|
Result R(MethList->Method, Results.getBasePriority(MethList->Method),0);
|
|
Result R(MethList->Method, Results.getBasePriority(MethList->Method),0);
|
|
- R.StartParameter = NumSelIdents;
|
|
|
|
|
|
+ R.StartParameter = SelIdents.size();
|
|
R.AllParametersAreInformative = false;
|
|
R.AllParametersAreInformative = false;
|
|
Results.MaybeAddResult(R, SemaRef.CurContext);
|
|
Results.MaybeAddResult(R, SemaRef.CurContext);
|
|
}
|
|
}
|
|
@@ -5488,8 +5476,7 @@ static void AddClassMessageCompletions(Sema &SemaRef, Scope *S,
|
|
}
|
|
}
|
|
|
|
|
|
void Sema::CodeCompleteObjCClassMessage(Scope *S, ParsedType Receiver,
|
|
void Sema::CodeCompleteObjCClassMessage(Scope *S, ParsedType Receiver,
|
|
- IdentifierInfo **SelIdents,
|
|
|
|
- unsigned NumSelIdents,
|
|
|
|
|
|
+ ArrayRef<IdentifierInfo *> SelIdents,
|
|
bool AtArgumentExpression,
|
|
bool AtArgumentExpression,
|
|
bool IsSuper) {
|
|
bool IsSuper) {
|
|
|
|
|
|
@@ -5498,9 +5485,9 @@ void Sema::CodeCompleteObjCClassMessage(Scope *S, ParsedType Receiver,
|
|
ResultBuilder Results(*this, CodeCompleter->getAllocator(),
|
|
ResultBuilder Results(*this, CodeCompleter->getAllocator(),
|
|
CodeCompleter->getCodeCompletionTUInfo(),
|
|
CodeCompleter->getCodeCompletionTUInfo(),
|
|
CodeCompletionContext(CodeCompletionContext::CCC_ObjCClassMessage,
|
|
CodeCompletionContext(CodeCompletionContext::CCC_ObjCClassMessage,
|
|
- T, SelIdents, NumSelIdents));
|
|
|
|
|
|
+ T, SelIdents));
|
|
|
|
|
|
- AddClassMessageCompletions(*this, S, Receiver, SelIdents, NumSelIdents,
|
|
|
|
|
|
+ AddClassMessageCompletions(*this, S, Receiver, SelIdents,
|
|
AtArgumentExpression, IsSuper, Results);
|
|
AtArgumentExpression, IsSuper, Results);
|
|
|
|
|
|
// If we're actually at the argument expression (rather than prior to the
|
|
// If we're actually at the argument expression (rather than prior to the
|
|
@@ -5510,7 +5497,7 @@ void Sema::CodeCompleteObjCClassMessage(Scope *S, ParsedType Receiver,
|
|
// our preferred type, improving completion results.
|
|
// our preferred type, improving completion results.
|
|
if (AtArgumentExpression) {
|
|
if (AtArgumentExpression) {
|
|
QualType PreferredType = getPreferredArgumentTypeForMessageSend(Results,
|
|
QualType PreferredType = getPreferredArgumentTypeForMessageSend(Results,
|
|
- NumSelIdents);
|
|
|
|
|
|
+ SelIdents.size());
|
|
if (PreferredType.isNull())
|
|
if (PreferredType.isNull())
|
|
CodeCompleteOrdinaryName(S, PCC_Expression);
|
|
CodeCompleteOrdinaryName(S, PCC_Expression);
|
|
else
|
|
else
|
|
@@ -5524,8 +5511,7 @@ void Sema::CodeCompleteObjCClassMessage(Scope *S, ParsedType Receiver,
|
|
}
|
|
}
|
|
|
|
|
|
void Sema::CodeCompleteObjCInstanceMessage(Scope *S, Expr *Receiver,
|
|
void Sema::CodeCompleteObjCInstanceMessage(Scope *S, Expr *Receiver,
|
|
- IdentifierInfo **SelIdents,
|
|
|
|
- unsigned NumSelIdents,
|
|
|
|
|
|
+ ArrayRef<IdentifierInfo *> SelIdents,
|
|
bool AtArgumentExpression,
|
|
bool AtArgumentExpression,
|
|
ObjCInterfaceDecl *Super) {
|
|
ObjCInterfaceDecl *Super) {
|
|
typedef CodeCompletionResult Result;
|
|
typedef CodeCompletionResult Result;
|
|
@@ -5553,7 +5539,7 @@ void Sema::CodeCompleteObjCInstanceMessage(Scope *S, Expr *Receiver,
|
|
if (ReceiverType->isObjCClassType())
|
|
if (ReceiverType->isObjCClassType())
|
|
return CodeCompleteObjCClassMessage(S,
|
|
return CodeCompleteObjCClassMessage(S,
|
|
ParsedType::make(Context.getObjCInterfaceType(IFace)),
|
|
ParsedType::make(Context.getObjCInterfaceType(IFace)),
|
|
- SelIdents, NumSelIdents,
|
|
|
|
|
|
+ SelIdents,
|
|
AtArgumentExpression, Super);
|
|
AtArgumentExpression, Super);
|
|
|
|
|
|
ReceiverType = Context.getObjCObjectPointerType(
|
|
ReceiverType = Context.getObjCObjectPointerType(
|
|
@@ -5564,7 +5550,7 @@ void Sema::CodeCompleteObjCInstanceMessage(Scope *S, Expr *Receiver,
|
|
ResultBuilder Results(*this, CodeCompleter->getAllocator(),
|
|
ResultBuilder Results(*this, CodeCompleter->getAllocator(),
|
|
CodeCompleter->getCodeCompletionTUInfo(),
|
|
CodeCompleter->getCodeCompletionTUInfo(),
|
|
CodeCompletionContext(CodeCompletionContext::CCC_ObjCInstanceMessage,
|
|
CodeCompletionContext(CodeCompletionContext::CCC_ObjCInstanceMessage,
|
|
- ReceiverType, SelIdents, NumSelIdents));
|
|
|
|
|
|
+ ReceiverType, SelIdents));
|
|
|
|
|
|
Results.EnterNewScope();
|
|
Results.EnterNewScope();
|
|
|
|
|
|
@@ -5572,8 +5558,7 @@ void Sema::CodeCompleteObjCInstanceMessage(Scope *S, Expr *Receiver,
|
|
// completion.
|
|
// completion.
|
|
if (Super) {
|
|
if (Super) {
|
|
if (ObjCMethodDecl *SuperMethod
|
|
if (ObjCMethodDecl *SuperMethod
|
|
- = AddSuperSendCompletion(*this, false, SelIdents, NumSelIdents,
|
|
|
|
- Results))
|
|
|
|
|
|
+ = AddSuperSendCompletion(*this, false, SelIdents, Results))
|
|
Results.Ignore(SuperMethod);
|
|
Results.Ignore(SuperMethod);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -5592,7 +5577,7 @@ void Sema::CodeCompleteObjCInstanceMessage(Scope *S, Expr *Receiver,
|
|
ReceiverType->isObjCQualifiedClassType()) {
|
|
ReceiverType->isObjCQualifiedClassType()) {
|
|
if (ObjCMethodDecl *CurMethod = getCurMethodDecl()) {
|
|
if (ObjCMethodDecl *CurMethod = getCurMethodDecl()) {
|
|
if (ObjCInterfaceDecl *ClassDecl = CurMethod->getClassInterface())
|
|
if (ObjCInterfaceDecl *ClassDecl = CurMethod->getClassInterface())
|
|
- AddObjCMethods(ClassDecl, false, MK_Any, SelIdents, NumSelIdents,
|
|
|
|
|
|
+ AddObjCMethods(ClassDecl, false, MK_Any, SelIdents,
|
|
CurContext, Selectors, AtArgumentExpression, Results);
|
|
CurContext, Selectors, AtArgumentExpression, Results);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -5603,7 +5588,7 @@ void Sema::CodeCompleteObjCInstanceMessage(Scope *S, Expr *Receiver,
|
|
for (ObjCObjectPointerType::qual_iterator I = QualID->qual_begin(),
|
|
for (ObjCObjectPointerType::qual_iterator I = QualID->qual_begin(),
|
|
E = QualID->qual_end();
|
|
E = QualID->qual_end();
|
|
I != E; ++I)
|
|
I != E; ++I)
|
|
- AddObjCMethods(*I, true, MK_Any, SelIdents, NumSelIdents, CurContext,
|
|
|
|
|
|
+ AddObjCMethods(*I, true, MK_Any, SelIdents, CurContext,
|
|
Selectors, AtArgumentExpression, Results);
|
|
Selectors, AtArgumentExpression, Results);
|
|
}
|
|
}
|
|
// Handle messages to a pointer to interface type.
|
|
// Handle messages to a pointer to interface type.
|
|
@@ -5611,14 +5596,14 @@ void Sema::CodeCompleteObjCInstanceMessage(Scope *S, Expr *Receiver,
|
|
= ReceiverType->getAsObjCInterfacePointerType()) {
|
|
= ReceiverType->getAsObjCInterfacePointerType()) {
|
|
// Search the class, its superclasses, etc., for instance methods.
|
|
// Search the class, its superclasses, etc., for instance methods.
|
|
AddObjCMethods(IFacePtr->getInterfaceDecl(), true, MK_Any, SelIdents,
|
|
AddObjCMethods(IFacePtr->getInterfaceDecl(), true, MK_Any, SelIdents,
|
|
- NumSelIdents, CurContext, Selectors, AtArgumentExpression,
|
|
|
|
|
|
+ CurContext, Selectors, AtArgumentExpression,
|
|
Results);
|
|
Results);
|
|
|
|
|
|
// Search protocols for instance methods.
|
|
// Search protocols for instance methods.
|
|
for (ObjCObjectPointerType::qual_iterator I = IFacePtr->qual_begin(),
|
|
for (ObjCObjectPointerType::qual_iterator I = IFacePtr->qual_begin(),
|
|
E = IFacePtr->qual_end();
|
|
E = IFacePtr->qual_end();
|
|
I != E; ++I)
|
|
I != E; ++I)
|
|
- AddObjCMethods(*I, true, MK_Any, SelIdents, NumSelIdents, CurContext,
|
|
|
|
|
|
+ AddObjCMethods(*I, true, MK_Any, SelIdents, CurContext,
|
|
Selectors, AtArgumentExpression, Results);
|
|
Selectors, AtArgumentExpression, Results);
|
|
}
|
|
}
|
|
// Handle messages to "id".
|
|
// Handle messages to "id".
|
|
@@ -5645,15 +5630,14 @@ void Sema::CodeCompleteObjCInstanceMessage(Scope *S, Expr *Receiver,
|
|
for (ObjCMethodList *MethList = &M->second.first;
|
|
for (ObjCMethodList *MethList = &M->second.first;
|
|
MethList && MethList->Method;
|
|
MethList && MethList->Method;
|
|
MethList = MethList->getNext()) {
|
|
MethList = MethList->getNext()) {
|
|
- if (!isAcceptableObjCMethod(MethList->Method, MK_Any, SelIdents,
|
|
|
|
- NumSelIdents))
|
|
|
|
|
|
+ if (!isAcceptableObjCMethod(MethList->Method, MK_Any, SelIdents))
|
|
continue;
|
|
continue;
|
|
|
|
|
|
if (!Selectors.insert(MethList->Method->getSelector()))
|
|
if (!Selectors.insert(MethList->Method->getSelector()))
|
|
continue;
|
|
continue;
|
|
|
|
|
|
Result R(MethList->Method, Results.getBasePriority(MethList->Method),0);
|
|
Result R(MethList->Method, Results.getBasePriority(MethList->Method),0);
|
|
- R.StartParameter = NumSelIdents;
|
|
|
|
|
|
+ R.StartParameter = SelIdents.size();
|
|
R.AllParametersAreInformative = false;
|
|
R.AllParametersAreInformative = false;
|
|
Results.MaybeAddResult(R, CurContext);
|
|
Results.MaybeAddResult(R, CurContext);
|
|
}
|
|
}
|
|
@@ -5669,7 +5653,7 @@ void Sema::CodeCompleteObjCInstanceMessage(Scope *S, Expr *Receiver,
|
|
// our preferred type, improving completion results.
|
|
// our preferred type, improving completion results.
|
|
if (AtArgumentExpression) {
|
|
if (AtArgumentExpression) {
|
|
QualType PreferredType = getPreferredArgumentTypeForMessageSend(Results,
|
|
QualType PreferredType = getPreferredArgumentTypeForMessageSend(Results,
|
|
- NumSelIdents);
|
|
|
|
|
|
+ SelIdents.size());
|
|
if (PreferredType.isNull())
|
|
if (PreferredType.isNull())
|
|
CodeCompleteOrdinaryName(S, PCC_Expression);
|
|
CodeCompleteOrdinaryName(S, PCC_Expression);
|
|
else
|
|
else
|
|
@@ -5698,8 +5682,8 @@ void Sema::CodeCompleteObjCForCollection(Scope *S,
|
|
CodeCompleteExpression(S, Data);
|
|
CodeCompleteExpression(S, Data);
|
|
}
|
|
}
|
|
|
|
|
|
-void Sema::CodeCompleteObjCSelector(Scope *S, IdentifierInfo **SelIdents,
|
|
|
|
- unsigned NumSelIdents) {
|
|
|
|
|
|
+void Sema::CodeCompleteObjCSelector(Scope *S,
|
|
|
|
+ ArrayRef<IdentifierInfo *> SelIdents) {
|
|
// If we have an external source, load the entire class method
|
|
// If we have an external source, load the entire class method
|
|
// pool from the AST file.
|
|
// pool from the AST file.
|
|
if (ExternalSource) {
|
|
if (ExternalSource) {
|
|
@@ -5722,7 +5706,7 @@ void Sema::CodeCompleteObjCSelector(Scope *S, IdentifierInfo **SelIdents,
|
|
M != MEnd; ++M) {
|
|
M != MEnd; ++M) {
|
|
|
|
|
|
Selector Sel = M->first;
|
|
Selector Sel = M->first;
|
|
- if (!isAcceptableObjCSelector(Sel, MK_Any, SelIdents, NumSelIdents))
|
|
|
|
|
|
+ if (!isAcceptableObjCSelector(Sel, MK_Any, SelIdents))
|
|
continue;
|
|
continue;
|
|
|
|
|
|
CodeCompletionBuilder Builder(Results.getAllocator(),
|
|
CodeCompletionBuilder Builder(Results.getAllocator(),
|
|
@@ -5736,7 +5720,7 @@ void Sema::CodeCompleteObjCSelector(Scope *S, IdentifierInfo **SelIdents,
|
|
|
|
|
|
std::string Accumulator;
|
|
std::string Accumulator;
|
|
for (unsigned I = 0, N = Sel.getNumArgs(); I != N; ++I) {
|
|
for (unsigned I = 0, N = Sel.getNumArgs(); I != N; ++I) {
|
|
- if (I == NumSelIdents) {
|
|
|
|
|
|
+ if (I == SelIdents.size()) {
|
|
if (!Accumulator.empty()) {
|
|
if (!Accumulator.empty()) {
|
|
Builder.AddInformativeChunk(Builder.getAllocator().CopyString(
|
|
Builder.AddInformativeChunk(Builder.getAllocator().CopyString(
|
|
Accumulator));
|
|
Accumulator));
|
|
@@ -7054,8 +7038,7 @@ void Sema::CodeCompleteObjCMethodDeclSelector(Scope *S,
|
|
bool IsInstanceMethod,
|
|
bool IsInstanceMethod,
|
|
bool AtParameterName,
|
|
bool AtParameterName,
|
|
ParsedType ReturnTy,
|
|
ParsedType ReturnTy,
|
|
- IdentifierInfo **SelIdents,
|
|
|
|
- unsigned NumSelIdents) {
|
|
|
|
|
|
+ ArrayRef<IdentifierInfo *> SelIdents) {
|
|
// If we have an external source, load the entire class method
|
|
// If we have an external source, load the entire class method
|
|
// pool from the AST file.
|
|
// pool from the AST file.
|
|
if (ExternalSource) {
|
|
if (ExternalSource) {
|
|
@@ -7086,12 +7069,12 @@ void Sema::CodeCompleteObjCMethodDeclSelector(Scope *S,
|
|
&M->second.second;
|
|
&M->second.second;
|
|
MethList && MethList->Method;
|
|
MethList && MethList->Method;
|
|
MethList = MethList->getNext()) {
|
|
MethList = MethList->getNext()) {
|
|
- if (!isAcceptableObjCMethod(MethList->Method, MK_Any, SelIdents,
|
|
|
|
- NumSelIdents))
|
|
|
|
|
|
+ if (!isAcceptableObjCMethod(MethList->Method, MK_Any, SelIdents))
|
|
continue;
|
|
continue;
|
|
|
|
|
|
if (AtParameterName) {
|
|
if (AtParameterName) {
|
|
// Suggest parameter names we've seen before.
|
|
// Suggest parameter names we've seen before.
|
|
|
|
+ unsigned NumSelIdents = SelIdents.size();
|
|
if (NumSelIdents && NumSelIdents <= MethList->Method->param_size()) {
|
|
if (NumSelIdents && NumSelIdents <= MethList->Method->param_size()) {
|
|
ParmVarDecl *Param = MethList->Method->param_begin()[NumSelIdents-1];
|
|
ParmVarDecl *Param = MethList->Method->param_begin()[NumSelIdents-1];
|
|
if (Param->getIdentifier()) {
|
|
if (Param->getIdentifier()) {
|
|
@@ -7107,7 +7090,7 @@ void Sema::CodeCompleteObjCMethodDeclSelector(Scope *S,
|
|
}
|
|
}
|
|
|
|
|
|
Result R(MethList->Method, Results.getBasePriority(MethList->Method), 0);
|
|
Result R(MethList->Method, Results.getBasePriority(MethList->Method), 0);
|
|
- R.StartParameter = NumSelIdents;
|
|
|
|
|
|
+ R.StartParameter = SelIdents.size();
|
|
R.AllParametersAreInformative = false;
|
|
R.AllParametersAreInformative = false;
|
|
R.DeclaringEntity = true;
|
|
R.DeclaringEntity = true;
|
|
Results.MaybeAddResult(R, CurContext);
|
|
Results.MaybeAddResult(R, CurContext);
|